Sign File or Buffer
[High Level API]


Functions

ops_boolean_t ops_sign_file_as_cleartext (const char *input_filename, const char *output_filename, const ops_secret_key_t *skey, const ops_boolean_t overwrite)
 Sign a file with a Cleartext Signature.
ops_boolean_t ops_sign_buf_as_cleartext (const char *cleartext, const size_t len, ops_memory_t **signed_cleartext, const ops_secret_key_t *skey)
 Sign a buffer with a Cleartext signature.
ops_boolean_t ops_sign_file (const char *input_filename, const char *output_filename, const ops_secret_key_t *skey, const ops_boolean_t use_armour, const ops_boolean_t overwrite)
 Sign a file.
ops_memory_tops_sign_buf (const void *input, const size_t input_len, const ops_sig_type_t sig_type, const ops_secret_key_t *skey, const ops_boolean_t use_armour, ops_boolean_t include_data)
 Signs a buffer.

Function Documentation

ops_memory_t* ops_sign_buf const void *  input,
const size_t  input_len,
const ops_sig_type_t  sig_type,
const ops_secret_key_t skey,
const ops_boolean_t  use_armour,
ops_boolean_t  include_data
 

Signs a buffer.

Parameters:
input Input text to be signed
input_len Length of input text
sig_type Signature type
skey Secret Key
use_armour Write armoured text, if set
include_data Includes the signed data in the output message. If not, creates a detached signature.
Returns:
New ops_memory_t struct containing signed text
Note:
It is the caller's responsibility to call ops_memory_free(me)
Example Code:
void example(const ops_secret_key_t *skey)
{
  const char* buf="Some example text";
  const size_t len=strlen(buf);
  const ops_boolean_t use_armour=ops_true;

  ops_memory_t* mem=NULL;
  
  mem=ops_sign_buf(buf,len,OPS_SIG_BINARY,skey,use_armour);
  if (mem)
  {
    printf ("OK");
    ops_memory_free(mem);
  }
  else
  {
    printf("ERR");
  }
}

ops_boolean_t ops_sign_buf_as_cleartext const char *  cleartext,
const size_t  len,
ops_memory_t **  signed_cleartext,
const ops_secret_key_t skey
 

Sign a buffer with a Cleartext signature.

Parameters:
cleartext Text to be signed
len Length of text
signed_cleartext ops_memory_t struct in which to write the signed cleartext
skey Secret key with which to sign the cleartext
Returns:
ops_true if OK; else ops_false
Note:
It is the calling function's responsibility to free signed_cleartext

signed_cleartext should be a NULL pointer when passed in

Example code:
 void example(const ops_secret_key_t *skey)
 {
   ops_memory_t* mem=NULL;
   const char* buf="Some example text";
   size_t len=strlen(buf);
   if (ops_sign_buf_as_cleartext(buf,len, &mem, skey)==ops_true)
     printf("OK");
   else
     printf("ERR");
   // free signed cleartext after use
   ops_memory_free(mem);
 }

ops_boolean_t ops_sign_file const char *  input_filename,
const char *  output_filename,
const ops_secret_key_t skey,
const ops_boolean_t  use_armour,
const ops_boolean_t  overwrite
 

Sign a file.

Parameters:
input_filename Input filename
output_filename Output filename. If NULL, a name is constructed from the input filename.
skey Secret Key to use for signing
use_armour Write armoured text, if set.
overwrite May overwrite existing file, if set.
Returns:
ops_true if OK; else ops_false;
Example code:
void example(const ops_secret_key_t *skey)
{
  const char* filename="mytestfile";
  const ops_boolean_t use_armour=ops_false;
  const ops_boolean_t overwrite=ops_false;
  if (ops_sign_file(filename, NULL, skey, use_armour, overwrite)==ops_true)
    printf("OK");
  else
    printf("ERR");  
}

ops_boolean_t ops_sign_file_as_cleartext const char *  input_filename,
const char *  output_filename,
const ops_secret_key_t skey,
const ops_boolean_t  overwrite
 

Sign a file with a Cleartext Signature.

Parameters:
input_filename Name of file to be signed
output_filename Filename to be created. If NULL, filename will be constructed from the input_filename.
skey Secret Key to sign with
overwrite Allow output file to be overwritten, if set
Returns:
ops_true if OK, else ops_false
Example code:
   void example(const ops_secret_key_t *skey, ops_boolean_t overwrite)
   {
   if (ops_sign_file_as_cleartext("mytestfile.txt",NULL,skey,overwrite)==ops_true)
       printf("OK");
   else
       printf("ERR");
   }


Generated on Sat May 25 00:00:02 2013 for OpenPGP:SDK by  doxygen 1.4.6