List Info

Thread: OpenSSL: openssl/doc/crypto/ EVP_PKEY_decrypt.pod EVP_PKEY_encry...




OpenSSL: openssl/doc/crypto/ EVP_PKEY_decrypt.pod EVP_PKEY_encry...
user name
2006-07-08 12:46:52
  OpenSSL CVS Repository
  http://cvs.openssl.org/
 
____________________________________________________________
________________

  Server: cvs.openssl.org                  Name:   Dr.
Stephen Henson
  Root:   /v/openssl/cvs                   Email:  steveopenssl.org
  Module: openssl                          Date:  
08-Jul-2006 14:46:52
  Branch: HEAD                             Handle:
2006070813465100

  Modified files:
    openssl/doc/crypto      EVP_PKEY_decrypt.pod
EVP_PKEY_encrypt.pod
                            EVP_PKEY_sign.pod
EVP_PKEY_verify.pod
                            EVP_PKEY_verifyrecover.pod

  Log:
    Add some examples.

  Summary:
    Revision    Changes     Path
    1.3         +31 -1     
openssl/doc/crypto/EVP_PKEY_decrypt.pod
    1.3         +31 -1     
openssl/doc/crypto/EVP_PKEY_encrypt.pod
    1.3         +35 -2     
openssl/doc/crypto/EVP_PKEY_sign.pod
    1.2         +26 -1     
openssl/doc/crypto/EVP_PKEY_verify.pod
    1.2         +33 -1     
openssl/doc/crypto/EVP_PKEY_verifyrecover.pod
 
____________________________________________________________
________________

  patch -p0 <<' .'
  Index: openssl/doc/crypto/EVP_PKEY_decrypt.pod
 
============================================================
================
  $ cvs diff -u -r1.2 -r1.3 EVP_PKEY_decrypt.pod
  --- openssl/doc/crypto/EVP_PKEY_decrypt.pod	8 Jul 2006
10:55:03 -0000	1.2
  +++ openssl/doc/crypto/EVP_PKEY_decrypt.pod	8 Jul 2006
12:46:51 -0000	1.3
   -45,7 +45,37 
   
   Decrypt data using OAEP (for RSA keys):
   
  -[to be added]
  + #include <openssl/evp.h>
  + #include <openssl/rsa.h>
  +
  + EVP_PKEY_CTX *ctx;
  + unsigned char *out, *in;
  + size_t outlen, inlen; 
  + EVP_PKEY *key;
  + /* NB: assumes key in, inlen are already set up
  +  * and that key is an RSA private key
  +  */
  + ctx = EVP_PKEY_CTX_new(key);
  + if (!ctx)
  +	/* Error occurred */
  + if (EVP_PKEY_decrypt_init(ctx) <= 0)
  +	/* Error */
  + if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_OAEP_PADDING)
<= 0)
  +	/* Error */
  +
  + /* Determine buffer length */
  + if (EVP_PKEY_decrypt(ctx, NULL, &outlen, in, inlen)
<= 0)
  +	/* Error */
  +
  + out = OPENSSL_malloc(outlen);
  +
  + if (!out)
  +	/* malloc failure */
  + 
  + if (EVP_PKEY_decrypt(ctx, out, &outlen, in, inlen)
<= 0)
  +	/* Error */
  +
  + /* Decrypted data is outlen bytes written to buffer out
*/
   
   =head1 SEE ALSO
   
   .
  patch -p0 <<' .'
  Index: openssl/doc/crypto/EVP_PKEY_encrypt.pod
 
============================================================
================
  $ cvs diff -u -r1.2 -r1.3 EVP_PKEY_encrypt.pod
  --- openssl/doc/crypto/EVP_PKEY_encrypt.pod	8 Jul 2006
10:55:03 -0000	1.2
  +++ openssl/doc/crypto/EVP_PKEY_encrypt.pod	8 Jul 2006
12:46:51 -0000	1.3
   -45,7 +45,37 
   
   Encrypt data using OAEP (for RSA keys):
   
  -[to be added]
  + #include <openssl/evp.h>
  + #include <openssl/rsa.h>
  +
  + EVP_PKEY_CTX *ctx;
  + unsigned char *out, *in;
  + size_t outlen, inlen; 
  + EVP_PKEY *key;
  + /* NB: assumes key in, inlen are already set up
  +  * and that key is an RSA public key
  +  */
  + ctx = EVP_PKEY_CTX_new(key);
  + if (!ctx)
  +	/* Error occurred */
  + if (EVP_PKEY_encrypt_init(ctx) <= 0)
  +	/* Error */
  + if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_OAEP_PADDING)
<= 0)
  +	/* Error */
  +
  + /* Determine buffer length */
  + if (EVP_PKEY_encrypt(ctx, NULL, &outlen, in, inlen)
<= 0)
  +	/* Error */
  +
  + out = OPENSSL_malloc(outlen);
  +
  + if (!out)
  +	/* malloc failure */
  + 
  + if (EVP_PKEY_encrypt(ctx, out, &outlen, in, inlen)
<= 0)
  +	/* Error */
  +
  + /* Encrypted data is outlen bytes written to buffer out
*/
   
   =head1 SEE ALSO
   
   .
  patch -p0 <<' .'
  Index: openssl/doc/crypto/EVP_PKEY_sign.pod
 
============================================================
================
  $ cvs diff -u -r1.2 -r1.3 EVP_PKEY_sign.pod
  --- openssl/doc/crypto/EVP_PKEY_sign.pod	8 Jul 2006
11:13:01 -0000	1.2
  +++ openssl/doc/crypto/EVP_PKEY_sign.pod	8 Jul 2006
12:46:51 -0000	1.3
   -43,9 +43,42 
   
   =head1 EXAMPLE
   
  -Sign data using PKCS#1 and SHA256 digest:
  +Sign data using RSA with PKCS#1 padding and SHA256
digest:
  +
  + #include <openssl/evp.h>
  + #include <openssl/rsa.h>
  +
  + EVP_PKEY_CTX *ctx;
  + unsigned char *md, *sig;
  + size_t mdlen, siglen; 
  + EVP_PKEY *signing_key;
  + /* NB: assumes signing_key, md and mdlen are already set
up
  +  * and that signing_key is an RSA private key
  +  */
  + ctx = EVP_PKEY_CTX_new(signing_key);
  + if (!ctx)
  +	/* Error occurred */
  + if (EVP_PKEY_sign_init(ctx) <= 0)
  +	/* Error */
  + if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING)
<= 0)
  +	/* Error */
  + if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256())
<= 0)
  +	/* Error */
  +
  + /* Determine buffer length */
  + if (EVP_PKEY_sign(ctx, NULL, &siglen, md, mdlen)
<= 0)
  +	/* Error */
  +
  + sig = OPENSSL_malloc(siglen);
  +
  + if (!sig)
  +	/* malloc failure */
  + 
  + if (EVP_PKEY_sign(ctx, sig, &siglen, md, mdlen)
<= 0)
  +	/* Error */
  +
  + /* Signature is siglen bytes written to buffer sig */
   
  -[to be added]
   
   =head1 SEE ALSO
   
   .
  patch -p0 <<' .'
  Index: openssl/doc/crypto/EVP_PKEY_verify.pod
 
============================================================
================
  $ cvs diff -u -r1.1 -r1.2 EVP_PKEY_verify.pod
  --- openssl/doc/crypto/EVP_PKEY_verify.pod	8 Jul 2006
11:22:23 -0000	1.1
  +++ openssl/doc/crypto/EVP_PKEY_verify.pod	8 Jul 2006
12:46:51 -0000	1.2
   -48,7 +48,32 
   
   Verify signature using PKCS#1 and SHA256 digest:
   
  -[to be added]
  + #include <openssl/evp.h>
  + #include <openssl/rsa.h>
  +
  + EVP_PKEY_CTX *ctx;
  + unsigned char *md, *sig;
  + size_t mdlen, siglen; 
  + EVP_PKEY *verify_key;
  + /* NB: assumes verify_key, sig, siglen md and mdlen are
already set up
  +  * and that verify_key is an RSA public key
  +  */
  + ctx = EVP_PKEY_CTX_new(verify_key);
  + if (!ctx)
  +	/* Error occurred */
  + if (EVP_PKEY_verify_init(ctx) <= 0)
  +	/* Error */
  + if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING)
<= 0)
  +	/* Error */
  + if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256())
<= 0)
  +	/* Error */
  +
  + /* Perform operation */
  + ret = EVP_PKEY_verify(ctx, md, mdlen, sig, siglen);
  +
  + /* ret == 1 indicates success, 0 verify failure and <
0 for some
  +  * other error.
  +  */
   
   =head1 SEE ALSO
   
   .
  patch -p0 <<' .'
  Index: openssl/doc/crypto/EVP_PKEY_verifyrecover.pod
 
============================================================
================
  $ cvs diff -u -r1.1 -r1.2 EVP_PKEY_verifyrecover.pod
  --- openssl/doc/crypto/EVP_PKEY_verifyrecover.pod	8 Jul
2006 11:13:01 -0000	1.1
  +++ openssl/doc/crypto/EVP_PKEY_verifyrecover.pod	8 Jul
2006 12:46:51 -0000	1.2
   -53,7 +53,39 
   
   Recover digest originally signed using PKCS#1 and SHA256
digest:
   
  -[to be added]
  + #include <openssl/evp.h>
  + #include <openssl/rsa.h>
  +
  + EVP_PKEY_CTX *ctx;
  + unsigned char *rout, *sig;
  + size_t routlen, siglen; 
  + EVP_PKEY *verify_key;
  + /* NB: assumes verify_key, sig and siglen are already
set up
  +  * and that verify_key is an RSA public key
  +  */
  + ctx = EVP_PKEY_CTX_new(verify_key);
  + if (!ctx)
  +	/* Error occurred */
  + if (EVP_PKEY_verifyrecover_init(ctx) <= 0)
  +	/* Error */
  + if (EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING)
<= 0)
  +	/* Error */
  + if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256())
<= 0)
  +	/* Error */
  +
  + /* Determine buffer length */
  + if (EVP_PKEY_verifyrecover(ctx, rout, &routlen, sig,
siglen) <= 0)
  +	/* Error */
  +
  + rout = OPENSSL_malloc(routlen);
  +
  + if (!rout)
  +	/* malloc failure */
  + 
  + if (EVP_PKEY_verifyrecover(ctx, rout, &routlen, sig,
siglen) <= 0)
  +	/* Error */
  +
  + /* Recovered data is routlen bytes written to buffer
rout */
   
   =head1 SEE ALSO
   
   .
____________________________________________________________
__________
OpenSSL Project                                 http://www.openssl.org
CVS Repository Commit List                    
openssl-cvsopenssl.org
Automated List Manager                          
majordomoopenssl.org
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )