From 5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80 Mon Sep 17 00:00:00 2001 From: djm <> Date: Sat, 6 Sep 2008 12:15:56 +0000 Subject: import of OpenSSL 0.9.8h --- src/lib/libcrypto/doc/DH_set_method.pod | 2 +- src/lib/libcrypto/doc/DSA_set_method.pod | 2 +- src/lib/libcrypto/doc/ERR_set_mark.pod | 38 +++++ src/lib/libcrypto/doc/EVP_BytesToKey.pod | 2 +- src/lib/libcrypto/doc/EVP_DigestInit.pod | 2 +- src/lib/libcrypto/doc/EVP_SealInit.pod | 6 +- src/lib/libcrypto/doc/PKCS12_create.pod | 18 +++ src/lib/libcrypto/doc/PKCS7_sign.pod | 24 ++- src/lib/libcrypto/doc/RAND_bytes.pod | 3 + src/lib/libcrypto/doc/RAND_set_rand_method.pod | 2 +- src/lib/libcrypto/doc/RSA_get_ex_new_index.pod | 12 +- src/lib/libcrypto/doc/RSA_set_method.pod | 2 +- src/lib/libcrypto/doc/RSA_sign.pod | 4 +- src/lib/libcrypto/doc/SMIME_write_PKCS7.pod | 14 +- src/lib/libcrypto/doc/X509_NAME_print_ex.pod | 4 +- src/lib/libcrypto/doc/bn.pod | 25 ++- src/lib/libcrypto/doc/d2i_X509.pod | 6 +- src/lib/libcrypto/doc/d2i_X509_CRL.pod | 2 +- src/lib/libcrypto/doc/d2i_X509_REQ.pod | 2 +- src/lib/libcrypto/doc/engine.pod | 212 +++++++++++-------------- src/lib/libcrypto/doc/x509.pod | 64 ++++++++ 21 files changed, 294 insertions(+), 152 deletions(-) create mode 100644 src/lib/libcrypto/doc/ERR_set_mark.pod create mode 100644 src/lib/libcrypto/doc/x509.pod (limited to 'src/lib/libcrypto/doc') diff --git a/src/lib/libcrypto/doc/DH_set_method.pod b/src/lib/libcrypto/doc/DH_set_method.pod index 73261fc467..d5cdc3be0c 100644 --- a/src/lib/libcrypto/doc/DH_set_method.pod +++ b/src/lib/libcrypto/doc/DH_set_method.pod @@ -36,7 +36,7 @@ structures created later. B: This is true only whilst no ENGINE has been set as a default for DH, so this function is no longer recommended. DH_get_default_method() returns a pointer to the current default DH_METHOD. -However, the meaningfulness of this result is dependant on whether the ENGINE +However, the meaningfulness of this result is dependent on whether the ENGINE API is being used, so this function is no longer recommended. DH_set_method() selects B to perform all operations using the key B. diff --git a/src/lib/libcrypto/doc/DSA_set_method.pod b/src/lib/libcrypto/doc/DSA_set_method.pod index bc3cfb1f0a..9c1434bd8d 100644 --- a/src/lib/libcrypto/doc/DSA_set_method.pod +++ b/src/lib/libcrypto/doc/DSA_set_method.pod @@ -36,7 +36,7 @@ structures created later. B: This is true only whilst no ENGINE has been set as a default for DSA, so this function is no longer recommended. DSA_get_default_method() returns a pointer to the current default -DSA_METHOD. However, the meaningfulness of this result is dependant on +DSA_METHOD. However, the meaningfulness of this result is dependent on whether the ENGINE API is being used, so this function is no longer recommended. diff --git a/src/lib/libcrypto/doc/ERR_set_mark.pod b/src/lib/libcrypto/doc/ERR_set_mark.pod new file mode 100644 index 0000000000..d3ca4f2e77 --- /dev/null +++ b/src/lib/libcrypto/doc/ERR_set_mark.pod @@ -0,0 +1,38 @@ +=pod + +=head1 NAME + +ERR_set_mark, ERR_pop_to_mark - set marks and pop errors until mark + +=head1 SYNOPSIS + + #include + + int ERR_set_mark(void); + + int ERR_pop_to_mark(void); + +=head1 DESCRIPTION + +ERR_set_mark() sets a mark on the current topmost error record if there +is one. + +ERR_pop_to_mark() will pop the top of the error stack until a mark is found. +The mark is then removed. If there is no mark, the whole stack is removed. + +=head1 RETURN VALUES + +ERR_set_mark() returns 0 if the error stack is empty, otherwise 1. + +ERR_pop_to_mark() returns 0 if there was no mark in the error stack, which +implies that the stack became empty, otherwise 1. + +=head1 SEE ALSO + +L + +=head1 HISTORY + +ERR_set_mark() and ERR_pop_to_mark() were added in OpenSSL 0.9.8. + +=cut diff --git a/src/lib/libcrypto/doc/EVP_BytesToKey.pod b/src/lib/libcrypto/doc/EVP_BytesToKey.pod index 016381f3e9..d375c46e03 100644 --- a/src/lib/libcrypto/doc/EVP_BytesToKey.pod +++ b/src/lib/libcrypto/doc/EVP_BytesToKey.pod @@ -60,7 +60,7 @@ EVP_BytesToKey() returns the size of the derived key in bytes. =head1 SEE ALSO L, L, -L, +L =head1 HISTORY diff --git a/src/lib/libcrypto/doc/EVP_DigestInit.pod b/src/lib/libcrypto/doc/EVP_DigestInit.pod index 1cb315e739..130cd7f60a 100644 --- a/src/lib/libcrypto/doc/EVP_DigestInit.pod +++ b/src/lib/libcrypto/doc/EVP_DigestInit.pod @@ -18,7 +18,7 @@ EVP digest routines EVP_MD_CTX *EVP_MD_CTX_create(void); int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); - int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); + int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt); int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s); diff --git a/src/lib/libcrypto/doc/EVP_SealInit.pod b/src/lib/libcrypto/doc/EVP_SealInit.pod index 48a0e29954..7d793e19ef 100644 --- a/src/lib/libcrypto/doc/EVP_SealInit.pod +++ b/src/lib/libcrypto/doc/EVP_SealInit.pod @@ -8,9 +8,9 @@ EVP_SealInit, EVP_SealUpdate, EVP_SealFinal - EVP envelope encryption #include - int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, - unsigned char **ek, int *ekl, unsigned char *iv, - EVP_PKEY **pubk, int npubk); + int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, + unsigned char **ek, int *ekl, unsigned char *iv, + EVP_PKEY **pubk, int npubk); int EVP_SealUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, unsigned char *in, int inl); int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, diff --git a/src/lib/libcrypto/doc/PKCS12_create.pod b/src/lib/libcrypto/doc/PKCS12_create.pod index 48f3bb8cb8..de7cab2bdf 100644 --- a/src/lib/libcrypto/doc/PKCS12_create.pod +++ b/src/lib/libcrypto/doc/PKCS12_create.pod @@ -46,6 +46,24 @@ export grade software which could use signing only keys of arbitrary size but had restrictions on the permissible sizes of keys which could be used for encryption. +=head1 NEW FUNCTIONALITY IN OPENSSL 0.9.8 + +Some additional functionality was added to PKCS12_create() in OpenSSL +0.9.8. These extensions are detailed below. + +If a certificate contains an B or B then this will be +used for the corresponding B or B in the +PKCS12 structure. + +Either B, B or both can be B to indicate that no key or +certficate is required. In previous versions both had to be present or +a fatal error is returned. + +B or B can be set to -1 indicating that no encryption +should be used. + +B can be set to -1 and the MAC will then be omitted entirely. + =head1 SEE ALSO L diff --git a/src/lib/libcrypto/doc/PKCS7_sign.pod b/src/lib/libcrypto/doc/PKCS7_sign.pod index fc7e649b34..ffd0c734b0 100644 --- a/src/lib/libcrypto/doc/PKCS7_sign.pod +++ b/src/lib/libcrypto/doc/PKCS7_sign.pod @@ -51,6 +51,24 @@ If present the SMIMECapabilities attribute indicates support for the following algorithms: triple DES, 128 bit RC2, 64 bit RC2, DES and 40 bit RC2. If any of these algorithms is disabled then it will not be included. +If the flags B is set then the returned B structure +is just initialized ready to perform the signing operation. The signing +is however B performed and the data to be signed is not read from +the B parameter. Signing is deferred until after the data has been +written. In this way data can be signed in a single pass. Currently the +flag B B also be set. + +=head1 NOTES + +Currently the flag B is only supported for detached +data. If this flag is set the returned B structure is B +complete and outputting its contents via a function that does not +properly finalize the B structure will give unpredictable +results. + +At present only the SMIME_write_PKCS7() function properly finalizes the +structure. + =head1 BUGS PKCS7_sign() is somewhat limited. It does not support multiple signers, some @@ -64,10 +82,6 @@ signed due to memory restraints. There should be a way to sign data without having to hold it all in memory, this would however require fairly major revisions of the OpenSSL ASN1 code. -Clear text signing does not store the content in memory but the way PKCS7_sign() -operates means that two passes of the data must typically be made: one to compute -the signatures and a second to output the data along with the signature. There -should be a way to process the data with only a single pass. =head1 RETURN VALUES @@ -82,4 +96,6 @@ L, L PKCS7_sign() was added to OpenSSL 0.9.5 +The B flag was added in OpenSSL 0.9.8 + =cut diff --git a/src/lib/libcrypto/doc/RAND_bytes.pod b/src/lib/libcrypto/doc/RAND_bytes.pod index ce6329ce54..1a9b91e281 100644 --- a/src/lib/libcrypto/doc/RAND_bytes.pod +++ b/src/lib/libcrypto/doc/RAND_bytes.pod @@ -25,6 +25,9 @@ unpredictable. They can be used for non-cryptographic purposes and for certain purposes in cryptographic protocols, but usually not for key generation etc. +The contents of B is mixed into the entropy pool before retrieving +the new pseudo-random bytes unless disabled at compile time (see FAQ). + =head1 RETURN VALUES RAND_bytes() returns 1 on success, 0 otherwise. The error code can be diff --git a/src/lib/libcrypto/doc/RAND_set_rand_method.pod b/src/lib/libcrypto/doc/RAND_set_rand_method.pod index c9bb6d9f27..e5b780fad0 100644 --- a/src/lib/libcrypto/doc/RAND_set_rand_method.pod +++ b/src/lib/libcrypto/doc/RAND_set_rand_method.pod @@ -30,7 +30,7 @@ true only whilst no ENGINE has been set as a default for RAND, so this function is no longer recommended. RAND_get_default_method() returns a pointer to the current RAND_METHOD. -However, the meaningfulness of this result is dependant on whether the ENGINE +However, the meaningfulness of this result is dependent on whether the ENGINE API is being used, so this function is no longer recommended. =head1 THE RAND_METHOD STRUCTURE diff --git a/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod b/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod index 46cc8f5359..7d0fd1f91d 100644 --- a/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod +++ b/src/lib/libcrypto/doc/RSA_get_ex_new_index.pod @@ -17,12 +17,12 @@ RSA_get_ex_new_index, RSA_set_ex_data, RSA_get_ex_data - add application specifi void *RSA_get_ex_data(RSA *r, int idx); - typedef int new_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); - typedef void free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); - typedef int dup_func(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, - int idx, long argl, void *argp); + typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); + typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, + int idx, long argl, void *argp); + typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, + int idx, long argl, void *argp); =head1 DESCRIPTION diff --git a/src/lib/libcrypto/doc/RSA_set_method.pod b/src/lib/libcrypto/doc/RSA_set_method.pod index 0a305f6b14..2c963d7e5b 100644 --- a/src/lib/libcrypto/doc/RSA_set_method.pod +++ b/src/lib/libcrypto/doc/RSA_set_method.pod @@ -42,7 +42,7 @@ structures created later. B: This is true only whilst no ENGINE has been set as a default for RSA, so this function is no longer recommended. RSA_get_default_method() returns a pointer to the current default -RSA_METHOD. However, the meaningfulness of this result is dependant on +RSA_METHOD. However, the meaningfulness of this result is dependent on whether the ENGINE API is being used, so this function is no longer recommended. diff --git a/src/lib/libcrypto/doc/RSA_sign.pod b/src/lib/libcrypto/doc/RSA_sign.pod index 71688a665e..8553be8e99 100644 --- a/src/lib/libcrypto/doc/RSA_sign.pod +++ b/src/lib/libcrypto/doc/RSA_sign.pod @@ -8,10 +8,10 @@ RSA_sign, RSA_verify - RSA signatures #include - int RSA_sign(int type, unsigned char *m, unsigned int m_len, + int RSA_sign(int type, const unsigned char *m, unsigned int m_len, unsigned char *sigret, unsigned int *siglen, RSA *rsa); - int RSA_verify(int type, unsigned char *m, unsigned int m_len, + int RSA_verify(int type, const unsigned char *m, unsigned int m_len, unsigned char *sigbuf, unsigned int siglen, RSA *rsa); =head1 DESCRIPTION diff --git a/src/lib/libcrypto/doc/SMIME_write_PKCS7.pod b/src/lib/libcrypto/doc/SMIME_write_PKCS7.pod index 2cfad2e049..61945b3887 100644 --- a/src/lib/libcrypto/doc/SMIME_write_PKCS7.pod +++ b/src/lib/libcrypto/doc/SMIME_write_PKCS7.pod @@ -30,18 +30,20 @@ If the B flag is set MIME headers for type B are added to the content, this only makes sense if B is also set. -If cleartext signing is being used then the data must be read twice: -once to compute the signature in PKCS7_sign() and once to output the -S/MIME message. +If the B flag is set the signed data is finalized +and output along with the content. This flag should only be set +if B is also set and the previous call to PKCS7_sign() +also set these flags. + +If cleartext signing is being used and B not set then +the data must be read twice: once to compute the signature in PKCS7_sign() +and once to output the S/MIME message. =head1 BUGS SMIME_write_PKCS7() always base64 encodes PKCS#7 structures, there should be an option to disable this. -There should really be a way to produce cleartext signing using only -a single pass of the data. - =head1 RETURN VALUES SMIME_write_PKCS7() returns 1 for success or 0 for failure. diff --git a/src/lib/libcrypto/doc/X509_NAME_print_ex.pod b/src/lib/libcrypto/doc/X509_NAME_print_ex.pod index 919b908919..2579a5dc9d 100644 --- a/src/lib/libcrypto/doc/X509_NAME_print_ex.pod +++ b/src/lib/libcrypto/doc/X509_NAME_print_ex.pod @@ -86,10 +86,10 @@ is equivalent to: B -B is a more readable one line format it is the same as: +B is a more readable one line format which is the same as: B -B is a multiline format is is the same as: +B is a multiline format which is the same as: B B uses a format identical to X509_NAME_print(): in fact it calls X509_NAME_print() internally. diff --git a/src/lib/libcrypto/doc/bn.pod b/src/lib/libcrypto/doc/bn.pod index 210dfeac08..cd2f8e50c6 100644 --- a/src/lib/libcrypto/doc/bn.pod +++ b/src/lib/libcrypto/doc/bn.pod @@ -27,6 +27,9 @@ bn - multiprecision integer arithmetics int BN_num_bits(const BIGNUM *a); int BN_num_bits_word(BN_ULONG w); + void BN_set_negative(BIGNUM *a, int n); + int BN_is_negative(const BIGNUM *a); + int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); @@ -118,6 +121,25 @@ bn - multiprecision integer arithmetics int BN_to_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx); + BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, + BIGNUM *mod); + void BN_BLINDING_free(BN_BLINDING *b); + int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); + int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); + int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); + int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, + BN_CTX *ctx); + int BN_BLINDING_invert_ex(BIGNUM *n,const BIGNUM *r,BN_BLINDING *b, + BN_CTX *ctx); + unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); + void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); + unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); + void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); + BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, + const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, + int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), + BN_MONT_CTX *m_ctx); =head1 DESCRIPTION @@ -153,6 +175,7 @@ L, L, L, L, L, L, L, L, -L +L, +L =cut diff --git a/src/lib/libcrypto/doc/d2i_X509.pod b/src/lib/libcrypto/doc/d2i_X509.pod index 5e3c3d0985..5bfa18afbb 100644 --- a/src/lib/libcrypto/doc/d2i_X509.pod +++ b/src/lib/libcrypto/doc/d2i_X509.pod @@ -9,7 +9,7 @@ i2d_X509_fp - X509 encode and decode functions #include - X509 *d2i_X509(X509 **px, unsigned char **in, int len); + X509 *d2i_X509(X509 **px, const unsigned char **in, int len); int i2d_X509(X509 *x, unsigned char **out); X509 *d2i_X509_bio(BIO *bp, X509 **x); @@ -23,13 +23,13 @@ i2d_X509_fp - X509 encode and decode functions The X509 encode and decode routines encode and parse an B structure, which represents an X509 certificate. -d2i_X509() attempts to decode B bytes at B<*out>. If +d2i_X509() attempts to decode B bytes at B<*in>. If successful a pointer to the B structure is returned. If an error occurred then B is returned. If B is not B then the returned structure is written to B<*px>. If B<*px> is not B then it is assumed that B<*px> contains a valid B structure and an attempt is made to reuse it. If the call is -successful B<*out> is incremented to the byte following the +successful B<*in> is incremented to the byte following the parsed data. i2d_X509() encodes the structure pointed to by B into DER format. diff --git a/src/lib/libcrypto/doc/d2i_X509_CRL.pod b/src/lib/libcrypto/doc/d2i_X509_CRL.pod index 06c5b23c09..e7295a5d61 100644 --- a/src/lib/libcrypto/doc/d2i_X509_CRL.pod +++ b/src/lib/libcrypto/doc/d2i_X509_CRL.pod @@ -9,7 +9,7 @@ i2d_X509_CRL_bio, i2d_X509_CRL_fp - PKCS#10 certificate request functions. #include - X509_CRL *d2i_X509_CRL(X509_CRL **a, unsigned char **pp, long length); + X509_CRL *d2i_X509_CRL(X509_CRL **a, const unsigned char **pp, long length); int i2d_X509_CRL(X509_CRL *a, unsigned char **pp); X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **x); diff --git a/src/lib/libcrypto/doc/d2i_X509_REQ.pod b/src/lib/libcrypto/doc/d2i_X509_REQ.pod index be4ad68257..ae32a3891d 100644 --- a/src/lib/libcrypto/doc/d2i_X509_REQ.pod +++ b/src/lib/libcrypto/doc/d2i_X509_REQ.pod @@ -9,7 +9,7 @@ i2d_X509_REQ_bio, i2d_X509_REQ_fp - PKCS#10 certificate request functions. #include - X509_REQ *d2i_X509_REQ(X509_REQ **a, unsigned char **pp, long length); + X509_REQ *d2i_X509_REQ(X509_REQ **a, const unsigned char **pp, long length); int i2d_X509_REQ(X509_REQ *a, unsigned char **pp); X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **x); diff --git a/src/lib/libcrypto/doc/engine.pod b/src/lib/libcrypto/doc/engine.pod index c77dad5562..f5ab1c3e50 100644 --- a/src/lib/libcrypto/doc/engine.pod +++ b/src/lib/libcrypto/doc/engine.pod @@ -23,21 +23,26 @@ engine - ENGINE cryptographic module support void ENGINE_load_openssl(void); void ENGINE_load_dynamic(void); - void ENGINE_load_cswift(void); - void ENGINE_load_chil(void); + #ifndef OPENSSL_NO_STATIC_ENGINE + void ENGINE_load_4758cca(void); + void ENGINE_load_aep(void); void ENGINE_load_atalla(void); + void ENGINE_load_chil(void); + void ENGINE_load_cswift(void); + void ENGINE_load_gmp(void); void ENGINE_load_nuron(void); - void ENGINE_load_ubsec(void); - void ENGINE_load_aep(void); void ENGINE_load_sureware(void); - void ENGINE_load_4758cca(void); - void ENGINE_load_openbsd_dev_crypto(void); + void ENGINE_load_ubsec(void); + #endif + void ENGINE_load_cryptodev(void); void ENGINE_load_builtin_engines(void); void ENGINE_cleanup(void); ENGINE *ENGINE_get_default_RSA(void); ENGINE *ENGINE_get_default_DSA(void); + ENGINE *ENGINE_get_default_ECDH(void); + ENGINE *ENGINE_get_default_ECDSA(void); ENGINE *ENGINE_get_default_DH(void); ENGINE *ENGINE_get_default_RAND(void); ENGINE *ENGINE_get_cipher_engine(int nid); @@ -45,6 +50,8 @@ engine - ENGINE cryptographic module support int ENGINE_set_default_RSA(ENGINE *e); int ENGINE_set_default_DSA(ENGINE *e); + int ENGINE_set_default_ECDH(ENGINE *e); + int ENGINE_set_default_ECDSA(ENGINE *e); int ENGINE_set_default_DH(ENGINE *e); int ENGINE_set_default_RAND(ENGINE *e); int ENGINE_set_default_ciphers(ENGINE *e); @@ -62,12 +69,21 @@ engine - ENGINE cryptographic module support int ENGINE_register_DSA(ENGINE *e); void ENGINE_unregister_DSA(ENGINE *e); void ENGINE_register_all_DSA(void); + int ENGINE_register_ECDH(ENGINE *e); + void ENGINE_unregister_ECDH(ENGINE *e); + void ENGINE_register_all_ECDH(void); + int ENGINE_register_ECDSA(ENGINE *e); + void ENGINE_unregister_ECDSA(ENGINE *e); + void ENGINE_register_all_ECDSA(void); int ENGINE_register_DH(ENGINE *e); void ENGINE_unregister_DH(ENGINE *e); void ENGINE_register_all_DH(void); int ENGINE_register_RAND(ENGINE *e); void ENGINE_unregister_RAND(ENGINE *e); void ENGINE_register_all_RAND(void); + int ENGINE_register_STORE(ENGINE *e); + void ENGINE_unregister_STORE(ENGINE *e); + void ENGINE_register_all_STORE(void); int ENGINE_register_ciphers(ENGINE *e); void ENGINE_unregister_ciphers(ENGINE *e); void ENGINE_register_all_ciphers(void); @@ -77,12 +93,12 @@ engine - ENGINE cryptographic module support int ENGINE_register_complete(ENGINE *e); int ENGINE_register_all_complete(void); - int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)()); + int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void)); int ENGINE_cmd_is_executable(ENGINE *e, int cmd); int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, - long i, void *p, void (*f)(), int cmd_optional); + long i, void *p, void (*f)(void), int cmd_optional); int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, - int cmd_optional); + int cmd_optional); int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); void *ENGINE_get_ex_data(const ENGINE *e, int idx); @@ -92,13 +108,17 @@ engine - ENGINE cryptographic module support ENGINE *ENGINE_new(void); int ENGINE_free(ENGINE *e); + int ENGINE_up_ref(ENGINE *e); int ENGINE_set_id(ENGINE *e, const char *id); int ENGINE_set_name(ENGINE *e, const char *name); int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); + int ENGINE_set_ECDH(ENGINE *e, const ECDH_METHOD *dh_meth); + int ENGINE_set_ECDSA(ENGINE *e, const ECDSA_METHOD *dh_meth); int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); + int ENGINE_set_STORE(ENGINE *e, const STORE_METHOD *rand_meth); int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); @@ -114,8 +134,11 @@ engine - ENGINE cryptographic module support const char *ENGINE_get_name(const ENGINE *e); const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); + const ECDH_METHOD *ENGINE_get_ECDH(const ENGINE *e); + const ECDSA_METHOD *ENGINE_get_ECDSA(const ENGINE *e); const DH_METHOD *ENGINE_get_DH(const ENGINE *e); const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); + const STORE_METHOD *ENGINE_get_STORE(const ENGINE *e); ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); @@ -148,7 +171,8 @@ The cryptographic functionality that can be provided by an B implementation includes the following abstractions; RSA_METHOD - for providing alternative RSA implementations - DSA_METHOD, DH_METHOD, RAND_METHOD - alternative DSA, DH, and RAND + DSA_METHOD, DH_METHOD, RAND_METHOD, ECDH_METHOD, ECDSA_METHOD, + STORE_METHOD - similarly for other OpenSSL APIs EVP_CIPHER - potentially multiple cipher algorithms (indexed by 'nid') EVP_DIGEST - potentially multiple hash algorithms (indexed by 'nid') key-loading - loading public and/or private EVP_PKEY keys @@ -157,52 +181,45 @@ implementation includes the following abstractions; Due to the modular nature of the ENGINE API, pointers to ENGINEs need to be treated as handles - ie. not only as pointers, but also as references to -the underlying ENGINE object. Ie. you should obtain a new reference when +the underlying ENGINE object. Ie. one should obtain a new reference when making copies of an ENGINE pointer if the copies will be used (and -released) independantly. +released) independently. ENGINE objects have two levels of reference-counting to match the way in which the objects are used. At the most basic level, each ENGINE pointer is -inherently a B reference - you need a structural reference -simply to refer to the pointer value at all, as this kind of reference is -your guarantee that the structure can not be deallocated until you release -your reference. - -However, a structural reference provides no guarantee that the ENGINE has -been initiliased to be usable to perform any of its cryptographic -implementations - and indeed it's quite possible that most ENGINEs will not -initialised at all on standard setups, as ENGINEs are typically used to +inherently a B reference - a structural reference is required +to use the pointer value at all, as this kind of reference is a guarantee +that the structure can not be deallocated until the reference is released. + +However, a structural reference provides no guarantee that the ENGINE is +initiliased and able to use any of its cryptographic +implementations. Indeed it's quite possible that most ENGINEs will not +initialise at all in typical environments, as ENGINEs are typically used to support specialised hardware. To use an ENGINE's functionality, you need a B reference. This kind of reference can be considered a specialised form of structural reference, because each functional reference implicitly contains a structural reference as well - however to avoid difficult-to-find programming bugs, it is recommended to treat the two -kinds of reference independantly. If you have a functional reference to an +kinds of reference independently. If you have a functional reference to an ENGINE, you have a guarantee that the ENGINE has been initialised ready to -perform cryptographic operations and will not be uninitialised or cleaned -up until after you have released your reference. - -We will discuss the two kinds of reference separately, including how to -tell which one you are dealing with at any given point in time (after all -they are both simply (ENGINE *) pointers, the difference is in the way they -are used). +perform cryptographic operations and will remain uninitialised +until after you have released your reference. I -This basic type of reference is typically used for creating new ENGINEs -dynamically, iterating across OpenSSL's internal linked-list of loaded +This basic type of reference is used for instantiating new ENGINEs, +iterating across OpenSSL's internal linked-list of loaded ENGINEs, reading information about an ENGINE, etc. Essentially a structural reference is sufficient if you only need to query or manipulate the data of an ENGINE implementation rather than use its functionality. The ENGINE_new() function returns a structural reference to a new (empty) -ENGINE object. Other than that, structural references come from return -values to various ENGINE API functions such as; ENGINE_by_id(), -ENGINE_get_first(), ENGINE_get_last(), ENGINE_get_next(), -ENGINE_get_prev(). All structural references should be released by a -corresponding to call to the ENGINE_free() function - the ENGINE object -itself will only actually be cleaned up and deallocated when the last -structural reference is released. +ENGINE object. There are other ENGINE API functions that return structural +references such as; ENGINE_by_id(), ENGINE_get_first(), ENGINE_get_last(), +ENGINE_get_next(), ENGINE_get_prev(). All structural references should be +released by a corresponding to call to the ENGINE_free() function - the +ENGINE object itself will only actually be cleaned up and deallocated when +the last structural reference is released. It should also be noted that many ENGINE API function calls that accept a structural reference will internally obtain another reference - typically @@ -237,15 +254,9 @@ call the ENGINE_init() function. This returns zero if the ENGINE was not already operational and couldn't be successfully initialised (eg. lack of system drivers, no special hardware attached, etc), otherwise it will return non-zero to indicate that the ENGINE is now operational and will -have allocated a new B reference to the ENGINE. In this case, -the supplied ENGINE pointer is, from the point of the view of the caller, -both a structural reference and a functional reference - so if the caller -intends to use it as a functional reference it should free the structural -reference with ENGINE_free() first. If the caller wishes to use it only as -a structural reference (eg. if the ENGINE_init() call was simply to test if -the ENGINE seems available/online), then it should free the functional -reference; all functional references are released by the ENGINE_finish() -function. +have allocated a new B reference to the ENGINE. All functional +references are released by calling ENGINE_finish() (which removes the +implicit structural reference as well). The second way to get a functional reference is by asking OpenSSL for a default implementation for a given task, eg. by ENGINE_get_default_RSA(), @@ -259,26 +270,21 @@ algorithm-specific types in OpenSSL, such as RSA, DSA, EVP_CIPHER_CTX, etc. For each supported abstraction, the ENGINE code maintains an internal table of state to control which implementations are available for a given abstraction and which should be used by default. These implementations are -registered in the tables separated-out by an 'nid' index, because +registered in the tables and indexed by an 'nid' value, because abstractions like EVP_CIPHER and EVP_DIGEST support many distinct -algorithms and modes - ENGINEs will support different numbers and -combinations of these. In the case of other abstractions like RSA, DSA, -etc, there is only one "algorithm" so all implementations implicitly -register using the same 'nid' index. ENGINEs can be B into -these tables to make themselves available for use automatically by the -various abstractions, eg. RSA. For illustrative purposes, we continue with -the RSA example, though all comments apply similarly to the other -abstractions (they each get their own table and linkage to the -corresponding section of openssl code). - -When a new RSA key is being created, ie. in RSA_new_method(), a -"get_default" call will be made to the ENGINE subsystem to process the RSA -state table and return a functional reference to an initialised ENGINE -whose RSA_METHOD should be used. If no ENGINE should (or can) be used, it -will return NULL and the RSA key will operate with a NULL ENGINE handle by -using the conventional RSA implementation in OpenSSL (and will from then on -behave the way it used to before the ENGINE API existed - for details see -L). +algorithms and modes, and ENGINEs can support arbitrarily many of them. +In the case of other abstractions like RSA, DSA, etc, there is only one +"algorithm" so all implementations implicitly register using the same 'nid' +index. + +When a default ENGINE is requested for a given abstraction/algorithm/mode, (eg. +when calling RSA_new_method(NULL)), a "get_default" call will be made to the +ENGINE subsystem to process the corresponding state table and return a +functional reference to an initialised ENGINE whose implementation should be +used. If no ENGINE should (or can) be used, it will return NULL and the caller +will operate with a NULL ENGINE handle - this usually equates to using the +conventional software implementation. In the latter case, OpenSSL will from +then on behave the way it used to before the ENGINE API existed. Each state table has a flag to note whether it has processed this "get_default" query since the table was last modified, because to process @@ -295,36 +301,9 @@ instead the only way for the state table to return a non-NULL ENGINE to the "get_default" query will be if one is expressly set in the table. Eg. ENGINE_set_default_RSA() does the same job as ENGINE_register_RSA() except that it also sets the state table's cached response for the "get_default" -query. - -In the case of abstractions like EVP_CIPHER, where implementations are -indexed by 'nid', these flags and cached-responses are distinct for each -'nid' value. - -It is worth illustrating the difference between "registration" of ENGINEs -into these per-algorithm state tables and using the alternative -"set_default" functions. The latter handles both "registration" and also -setting the cached "default" ENGINE in each relevant state table - so -registered ENGINEs will only have a chance to be initialised for use as a -default if a default ENGINE wasn't already set for the same state table. -Eg. if ENGINE X supports cipher nids {A,B} and RSA, ENGINE Y supports -ciphers {A} and DSA, and the following code is executed; - - ENGINE_register_complete(X); - ENGINE_set_default(Y, ENGINE_METHOD_ALL); - e1 = ENGINE_get_default_RSA(); - e2 = ENGINE_get_cipher_engine(A); - e3 = ENGINE_get_cipher_engine(B); - e4 = ENGINE_get_default_DSA(); - e5 = ENGINE_get_cipher_engine(C); - -The results would be as follows; - - assert(e1 == X); - assert(e2 == Y); - assert(e3 == X); - assert(e4 == Y); - assert(e5 == NULL); +query. In the case of abstractions like EVP_CIPHER, where implementations are +indexed by 'nid', these flags and cached-responses are distinct for each 'nid' +value. =head2 Application requirements @@ -360,7 +339,7 @@ mention an important API function; If no ENGINE API functions are called at all in an application, then there are no inherent memory leaks to worry about from the ENGINE functionality, -however if any ENGINEs are "load"ed, even if they are never registered or +however if any ENGINEs are loaded, even if they are never registered or used, it is necessary to use the ENGINE_cleanup() function to correspondingly cleanup before program exit, if the caller wishes to avoid memory leaks. This mechanism uses an internal callback registration table @@ -375,7 +354,7 @@ linker. The fact that ENGINEs are made visible to OpenSSL (and thus are linked into the program and loaded into memory at run-time) does not mean they are "registered" or called into use by OpenSSL automatically - that behaviour -is something for the application to have control over. Some applications +is something for the application to control. Some applications will want to allow the user to specify exactly which ENGINE they want used if any is to be used at all. Others may prefer to load all support and have OpenSSL automatically use at run-time any ENGINE that is able to @@ -433,7 +412,7 @@ it should be used. The following code illustrates how this can work; That's all that's required. Eg. the next time OpenSSL tries to set up an RSA key, any bundled ENGINEs that implement RSA_METHOD will be passed to ENGINE_init() and if any of those succeed, that ENGINE will be set as the -default for use with RSA from then on. +default for RSA use from then on. =head2 Advanced configuration support @@ -441,7 +420,7 @@ There is a mechanism supported by the ENGINE framework that allows each ENGINE implementation to define an arbitrary set of configuration "commands" and expose them to OpenSSL and any applications based on OpenSSL. This mechanism is entirely based on the use of name-value pairs -and and assumes ASCII input (no unicode or UTF for now!), so it is ideal if +and assumes ASCII input (no unicode or UTF for now!), so it is ideal if applications want to provide a transparent way for users to provide arbitrary configuration "directives" directly to such ENGINEs. It is also possible for the application to dynamically interrogate the loaded ENGINE @@ -450,8 +429,8 @@ available "control commands", providing a more flexible configuration scheme. However, if the user is expected to know which ENGINE device he/she is using (in the case of specialised hardware, this goes without saying) then applications may not need to concern themselves with discovering the -supported control commands and simply prefer to allow settings to passed -into ENGINEs exactly as they are provided by the user. +supported control commands and simply prefer to pass settings into ENGINEs +exactly as they are provided by the user. Before illustrating how control commands work, it is worth mentioning what they are typically used for. Broadly speaking there are two uses for @@ -459,13 +438,13 @@ control commands; the first is to provide the necessary details to the implementation (which may know nothing at all specific to the host system) so that it can be initialised for use. This could include the path to any driver or config files it needs to load, required network addresses, -smart-card identifiers, passwords to initialise password-protected devices, +smart-card identifiers, passwords to initialise protected devices, logging information, etc etc. This class of commands typically needs to be passed to an ENGINE B attempting to initialise it, ie. before calling ENGINE_init(). The other class of commands consist of settings or operations that tweak certain behaviour or cause certain operations to take place, and these commands may work either before or after ENGINE_init(), or -in same cases both. ENGINE implementations should provide indications of +in some cases both. ENGINE implementations should provide indications of this in the descriptions attached to builtin control commands and/or in external product documentation. @@ -529,14 +508,14 @@ FALSE. I It is possible to discover at run-time the names, numerical-ids, descriptions -and input parameters of the control commands supported from a structural -reference to any ENGINE. It is first important to note that some control -commands are defined by OpenSSL itself and it will intercept and handle these -control commands on behalf of the ENGINE, ie. the ENGINE's ctrl() handler is not -used for the control command. openssl/engine.h defines a symbol, -ENGINE_CMD_BASE, that all control commands implemented by ENGINEs from. Any -command value lower than this symbol is considered a "generic" command is -handled directly by the OpenSSL core routines. +and input parameters of the control commands supported by an ENGINE using a +structural reference. Note that some control commands are defined by OpenSSL +itself and it will intercept and handle these control commands on behalf of the +ENGINE, ie. the ENGINE's ctrl() handler is not used for the control command. +openssl/engine.h defines an index, ENGINE_CMD_BASE, that all control commands +implemented by ENGINEs should be numbered from. Any command value lower than +this symbol is considered a "generic" command is handled directly by the +OpenSSL core routines. It is using these "core" control commands that one can discover the the control commands implemented by a given ENGINE, specifically the commands; @@ -552,8 +531,8 @@ commands implemented by a given ENGINE, specifically the commands; #define ENGINE_CTRL_GET_CMD_FLAGS 18 Whilst these commands are automatically processed by the OpenSSL framework code, -they use various properties exposed by each ENGINE by which to process these -queries. An ENGINE has 3 properties it exposes that can affect this behaviour; +they use various properties exposed by each ENGINE to process these +queries. An ENGINE has 3 properties it exposes that can affect how this behaves; it can supply a ctrl() handler, it can specify ENGINE_FLAGS_MANUAL_CMD_CTRL in the ENGINE's flags, and it can expose an array of control command descriptions. If an ENGINE specifies the ENGINE_FLAGS_MANUAL_CMD_CTRL flag, then it will @@ -608,14 +587,13 @@ extension). The ENGINE API and internal architecture is currently being reviewed. Slated for possible release in 0.9.8 is support for transparent loading of "dynamic" ENGINEs (built as self-contained shared-libraries). This would allow ENGINE -implementations to be provided independantly of OpenSSL libraries and/or +implementations to be provided independently of OpenSSL libraries and/or OpenSSL-based applications, and would also remove any requirement for applications to explicitly use the "dynamic" ENGINE to bind to shared-library implementations. =head1 SEE ALSO -L, L, L, L, -L +L, L, L, L =cut diff --git a/src/lib/libcrypto/doc/x509.pod b/src/lib/libcrypto/doc/x509.pod new file mode 100644 index 0000000000..f9e58e0e41 --- /dev/null +++ b/src/lib/libcrypto/doc/x509.pod @@ -0,0 +1,64 @@ +=pod + +=head1 NAME + +x509 - X.509 certificate handling + +=head1 SYNOPSIS + + #include + +=head1 DESCRIPTION + +A X.509 certificate is a structured grouping of information about +an individual, a device, or anything one can imagine. A X.509 CRL +(certificate revocation list) is a tool to help determine if a +certificate is still valid. The exact definition of those can be +found in the X.509 document from ITU-T, or in RFC3280 from PKIX. +In OpenSSL, the type X509 is used to express such a certificate, and +the type X509_CRL is used to express a CRL. + +A related structure is a certificate request, defined in PKCS#10 from +RSA Security, Inc, also reflected in RFC2896. In OpenSSL, the type +X509_REQ is used to express such a certificate request. + +To handle some complex parts of a certificate, there are the types +X509_NAME (to express a certificate name), X509_ATTRIBUTE (to express +a certificate attributes), X509_EXTENSION (to express a certificate +extension) and a few more. + +Finally, there's the supertype X509_INFO, which can contain a CRL, a +certificate and a corresponding private key. + +BI<...>, BI<...> and BI<...> handle X.509 +certificates, with some exceptions, shown below. + +BI<...>, BI<...> and BI<...> +handle X.509 CRLs. + +BI<...>, BI<...> and BI<...> +handle PKCS#10 certificate requests. + +BI<...> handle certificate names. + +BI<...> handle certificate attributes. + +BI<...> handle certificate extensions. + +=head1 SEE ALSO + +L, +L, +L, +L, +L, +L, +L, +L, +L, +L, +L, +L, +L + +=cut -- cgit v1.2.3-55-g6feb