00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #ifndef HEADER_ENVELOPE_H
00063 #define HEADER_ENVELOPE_H
00064
00065 #if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
00066 #define SYMBIAN
00067 #endif
00068
00069 #ifdef SYMBIAN
00070 #include <e32def.h>
00071 #endif
00072 #ifdef OPENSSL_ALGORITHM_DEFINES
00073 # include <openssl/opensslconf.h>
00074 #else
00075 # define OPENSSL_ALGORITHM_DEFINES
00076 # include <openssl/opensslconf.h>
00077 # undef OPENSSL_ALGORITHM_DEFINES
00078 #endif
00079
00080 #include <openssl/ossl_typ.h>
00081
00082 #include <openssl/symhacks.h>
00083
00084 #ifndef OPENSSL_NO_BIO
00085 #include <openssl/bio.h>
00086 #endif
00087
00088
00089
00090
00091
00092
00093
00094
00095 #define EVP_MAX_MD_SIZE 64
00096 #define EVP_MAX_KEY_LENGTH 32
00097 #define EVP_MAX_IV_LENGTH 16
00098 #define EVP_MAX_BLOCK_LENGTH 32
00099
00100 #define PKCS5_SALT_LEN 8
00101
00102 #define PKCS5_DEFAULT_ITER 2048
00103
00104 #include <openssl/objects.h>
00105
00106 #define EVP_PK_RSA 0x0001
00107 #define EVP_PK_DSA 0x0002
00108 #define EVP_PK_DH 0x0004
00109 #define EVP_PK_EC 0x0008
00110 #define EVP_PKT_SIGN 0x0010
00111 #define EVP_PKT_ENC 0x0020
00112 #define EVP_PKT_EXCH 0x0040
00113 #define EVP_PKS_RSA 0x0100
00114 #define EVP_PKS_DSA 0x0200
00115 #define EVP_PKS_EC 0x0400
00116 #define EVP_PKT_EXP 0x1000
00117
00118 #define EVP_PKEY_NONE NID_undef
00119 #define EVP_PKEY_RSA NID_rsaEncryption
00120 #define EVP_PKEY_RSA2 NID_rsa
00121 #define EVP_PKEY_DSA NID_dsa
00122 #define EVP_PKEY_DSA1 NID_dsa_2
00123 #define EVP_PKEY_DSA2 NID_dsaWithSHA
00124 #define EVP_PKEY_DSA3 NID_dsaWithSHA1
00125 #define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
00126 #define EVP_PKEY_DH NID_dhKeyAgreement
00127 #define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
00128
00129 #ifdef __cplusplus
00130 extern "C" {
00131 #endif
00132
00133
00134
00135
00136 struct evp_pkey_st
00137 {
00138 int type;
00139 int save_type;
00140 int references;
00141 union {
00142 char *ptr;
00143 #ifndef OPENSSL_NO_RSA
00144 struct rsa_st *rsa;
00145 #endif
00146 #ifndef OPENSSL_NO_DSA
00147 struct dsa_st *dsa;
00148 #endif
00149 #ifndef OPENSSL_NO_DH
00150 struct dh_st *dh;
00151 #endif
00152 #ifndef OPENSSL_NO_EC
00153 struct ec_key_st *ec;
00154 #endif
00155 } pkey;
00156 int save_parameters;
00157 STACK_OF(X509_ATTRIBUTE) *attributes;
00158 } ;
00159
00160 #define EVP_PKEY_MO_SIGN 0x0001
00161 #define EVP_PKEY_MO_VERIFY 0x0002
00162 #define EVP_PKEY_MO_ENCRYPT 0x0004
00163 #define EVP_PKEY_MO_DECRYPT 0x0008
00164
00165 #if 0
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 typedef struct evp_pkey_md_st
00177 {
00178 int oid;
00179 EVP_MD *md;
00180 EVP_PKEY_METHOD *pkey;
00181 } EVP_PKEY_MD;
00182
00183 #define EVP_rsa_md2() \
00184 EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\
00185 EVP_rsa_pkcs1(),EVP_md2())
00186 #define EVP_rsa_md5() \
00187 EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\
00188 EVP_rsa_pkcs1(),EVP_md5())
00189 #define EVP_rsa_sha0() \
00190 EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\
00191 EVP_rsa_pkcs1(),EVP_sha())
00192 #define EVP_rsa_sha1() \
00193 EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\
00194 EVP_rsa_pkcs1(),EVP_sha1())
00195 #define EVP_rsa_ripemd160() \
00196 EVP_PKEY_MD_add(NID_ripemd160WithRSA,\
00197 EVP_rsa_pkcs1(),EVP_ripemd160())
00198 #define EVP_rsa_mdc2() \
00199 EVP_PKEY_MD_add(NID_mdc2WithRSA,\
00200 EVP_rsa_octet_string(),EVP_mdc2())
00201 #define EVP_dsa_sha() \
00202 EVP_PKEY_MD_add(NID_dsaWithSHA,\
00203 EVP_dsa(),EVP_sha())
00204 #define EVP_dsa_sha1() \
00205 EVP_PKEY_MD_add(NID_dsaWithSHA1,\
00206 EVP_dsa(),EVP_sha1())
00207
00208 typedef struct evp_pkey_method_st
00209 {
00210 char *name;
00211 int flags;
00212 int type;
00213 int oid;
00214 int encrypt_oid;
00215
00216 int (*sign)();
00217 int (*verify)();
00218 struct {
00219 int (*set)();
00220 int (*get)();
00221 int (*encrypt)();
00222 int (*decrypt)();
00223 int (*i2d)();
00224 int (*d2i)();
00225 int (*dup)();
00226 } pub,priv;
00227 int (*set_asn1_parameters)();
00228 int (*get_asn1_parameters)();
00229 } EVP_PKEY_METHOD;
00230 #endif
00231
00232 #ifndef EVP_MD
00233 struct env_md_st
00234 {
00235 int type;
00236 int pkey_type;
00237 int md_size;
00238 unsigned long flags;
00239 int (*init)(EVP_MD_CTX *ctx);
00240 int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count);
00241 int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
00242 int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
00243 int (*cleanup)(EVP_MD_CTX *ctx);
00244
00245
00246 int (*sign)(int type, const unsigned char *m, unsigned int m_length,
00247 unsigned char *sigret, unsigned int *siglen, void *key);
00248 int (*verify)(int type, const unsigned char *m, unsigned int m_length,
00249 const unsigned char *sigbuf, unsigned int siglen,
00250 void *key);
00251 int required_pkey_type[5];
00252 int block_size;
00253 int ctx_size;
00254 } ;
00255
00256 typedef int evp_sign_method(int type,const unsigned char *m,
00257 unsigned int m_length,unsigned char *sigret,
00258 unsigned int *siglen, void *key);
00259 typedef int evp_verify_method(int type,const unsigned char *m,
00260 unsigned int m_length,const unsigned char *sigbuf,
00261 unsigned int siglen, void *key);
00262
00263 #define EVP_MD_FLAG_ONESHOT 0x0001
00264
00265
00266 #define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
00267
00268 #ifndef OPENSSL_NO_DSA
00269 #define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \
00270 (evp_verify_method *)DSA_verify, \
00271 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \
00272 EVP_PKEY_DSA4,0}
00273 #else
00274 #define EVP_PKEY_DSA_method EVP_PKEY_NULL_method
00275 #endif
00276
00277 #ifndef OPENSSL_NO_ECDSA
00278 #define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \
00279 (evp_verify_method *)ECDSA_verify, \
00280 {EVP_PKEY_EC,0,0,0}
00281 #else
00282 #define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method
00283 #endif
00284
00285 #ifndef OPENSSL_NO_RSA
00286 #define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \
00287 (evp_verify_method *)RSA_verify, \
00288 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
00289 #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \
00290 (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \
00291 (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \
00292 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
00293 #else
00294 #define EVP_PKEY_RSA_method EVP_PKEY_NULL_method
00295 #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method
00296 #endif
00297
00298 #endif
00299
00300 struct env_md_ctx_st
00301 {
00302 const EVP_MD *digest;
00303 ENGINE *engine;
00304 unsigned long flags;
00305 void *md_data;
00306 } ;
00307
00308
00309
00310 #define EVP_MD_CTX_FLAG_ONESHOT 0x0001
00311
00312 #define EVP_MD_CTX_FLAG_CLEANED 0x0002
00313
00314 #define EVP_MD_CTX_FLAG_REUSE 0x0004
00315
00316
00317 struct evp_cipher_st
00318 {
00319 int nid;
00320 int block_size;
00321 int key_len;
00322 int iv_len;
00323 unsigned long flags;
00324 int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
00325 const unsigned char *iv, int enc);
00326 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
00327 const unsigned char *in, unsigned int inl);
00328 int (*cleanup)(EVP_CIPHER_CTX *);
00329 int ctx_size;
00330 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *);
00331 int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *);
00332 int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr);
00333 void *app_data;
00334 } ;
00335
00336
00337
00338
00339
00340 #define EVP_CIPH_STREAM_CIPHER 0x0
00341 #define EVP_CIPH_ECB_MODE 0x1
00342 #define EVP_CIPH_CBC_MODE 0x2
00343 #define EVP_CIPH_CFB_MODE 0x3
00344 #define EVP_CIPH_OFB_MODE 0x4
00345 #define EVP_CIPH_MODE 0x7
00346
00347 #define EVP_CIPH_VARIABLE_LENGTH 0x8
00348
00349 #define EVP_CIPH_CUSTOM_IV 0x10
00350
00351 #define EVP_CIPH_ALWAYS_CALL_INIT 0x20
00352
00353 #define EVP_CIPH_CTRL_INIT 0x40
00354
00355 #define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
00356
00357 #define EVP_CIPH_NO_PADDING 0x100
00358
00359 #define EVP_CIPH_RAND_KEY 0x200
00360
00361
00362
00363 #define EVP_CTRL_INIT 0x0
00364 #define EVP_CTRL_SET_KEY_LENGTH 0x1
00365 #define EVP_CTRL_GET_RC2_KEY_BITS 0x2
00366 #define EVP_CTRL_SET_RC2_KEY_BITS 0x3
00367 #define EVP_CTRL_GET_RC5_ROUNDS 0x4
00368 #define EVP_CTRL_SET_RC5_ROUNDS 0x5
00369 #define EVP_CTRL_RAND_KEY 0x6
00370
00371 typedef struct evp_cipher_info_st
00372 {
00373 const EVP_CIPHER *cipher;
00374 unsigned char iv[EVP_MAX_IV_LENGTH];
00375 } EVP_CIPHER_INFO;
00376
00377 struct evp_cipher_ctx_st
00378 {
00379 const EVP_CIPHER *cipher;
00380 ENGINE *engine;
00381 int encrypt;
00382 int buf_len;
00383
00384 unsigned char oiv[EVP_MAX_IV_LENGTH];
00385 unsigned char iv[EVP_MAX_IV_LENGTH];
00386 unsigned char buf[EVP_MAX_BLOCK_LENGTH];
00387 int num;
00388
00389 void *app_data;
00390 int key_len;
00391 unsigned long flags;
00392 void *cipher_data;
00393 int final_used;
00394 int block_mask;
00395 unsigned char final[EVP_MAX_BLOCK_LENGTH];
00396 } ;
00397
00398 typedef struct evp_Encode_Ctx_st
00399 {
00400 int num;
00401 int length;
00402
00403
00404
00405
00406 unsigned char enc_data[80];
00407 int line_num;
00408 int expect_nl;
00409 } EVP_ENCODE_CTX;
00410
00411
00412 typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
00413 ASN1_TYPE *param, const EVP_CIPHER *cipher,
00414 const EVP_MD *md, int en_de);
00415
00416 #ifndef OPENSSL_NO_RSA
00417 #define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
00418 (char *)(rsa))
00419 #endif
00420
00421 #ifndef OPENSSL_NO_DSA
00422 #define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
00423 (char *)(dsa))
00424 #endif
00425
00426 #ifndef OPENSSL_NO_DH
00427 #define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
00428 (char *)(dh))
00429 #endif
00430
00431 #ifndef OPENSSL_NO_EC
00432 #define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
00433 (char *)(eckey))
00434 #endif
00435
00436
00437 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
00438 #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
00439 #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
00440 #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
00441
00442 #define EVP_MD_type(e) ((e)->type)
00443 #define EVP_MD_nid(e) EVP_MD_type(e)
00444 #define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
00445 #define EVP_MD_pkey_type(e) ((e)->pkey_type)
00446 #define EVP_MD_size(e) ((e)->md_size)
00447 #define EVP_MD_block_size(e) ((e)->block_size)
00448
00449 #define EVP_MD_CTX_md(e) ((e)->digest)
00450 #define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
00451 #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
00452 #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
00453
00454 #define EVP_CIPHER_nid(e) ((e)->nid)
00455 #define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
00456 #define EVP_CIPHER_block_size(e) ((e)->block_size)
00457 #define EVP_CIPHER_key_length(e) ((e)->key_len)
00458 #define EVP_CIPHER_iv_length(e) ((e)->iv_len)
00459 #define EVP_CIPHER_flags(e) ((e)->flags)
00460 #define EVP_CIPHER_mode(e) (((e)->flags) & EVP_CIPH_MODE)
00461
00462 #define EVP_CIPHER_CTX_cipher(e) ((e)->cipher)
00463 #define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid)
00464 #define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size)
00465 #define EVP_CIPHER_CTX_key_length(e) ((e)->key_len)
00466 #define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len)
00467 #define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
00468 #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d))
00469 #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
00470 #define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags)
00471 #define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE)
00472
00473 #define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
00474 #define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
00475
00476 #define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
00477 #define EVP_SignInit(a,b) EVP_DigestInit(a,b)
00478 #define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
00479 #define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
00480 #define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
00481 #define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
00482 #define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
00483 #define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
00484
00485 #ifdef CONST_STRICT
00486 IMPORT_C void BIO_set_md(BIO *,const EVP_MD *md);
00487 #else
00488 # define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)
00489 #endif
00490 #define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)
00491 #define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)
00492 #define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
00493 #define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)
00494
00495 #define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l))
00496
00497 #define EVP_add_cipher_alias(n,alias) \
00498 OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
00499 #define EVP_add_digest_alias(n,alias) \
00500 OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
00501 #define EVP_delete_cipher_alias(alias) \
00502 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
00503 #define EVP_delete_digest_alias(alias) \
00504 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
00505
00506 IMPORT_C void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
00507 IMPORT_C int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
00508 IMPORT_C EVP_MD_CTX *EVP_MD_CTX_create(void);
00509 IMPORT_C void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
00510 IMPORT_C int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
00511 #define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
00512 #define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
00513 #define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
00514 IMPORT_C int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
00515 IMPORT_C int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
00516 size_t cnt);
00517 IMPORT_C int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
00518 IMPORT_C int EVP_Digest(const void *data, size_t count,
00519 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
00520
00521 IMPORT_C int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);
00522 IMPORT_C int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
00523 IMPORT_C int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
00524
00525 IMPORT_C int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
00526 IMPORT_C void EVP_set_pw_prompt(const char *prompt);
00527 IMPORT_C char * EVP_get_pw_prompt(void);
00528
00529 IMPORT_C int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
00530 const unsigned char *salt, const unsigned char *data,
00531 int datal, int count, unsigned char *key,unsigned char *iv);
00532
00533 IMPORT_C int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
00534 const unsigned char *key, const unsigned char *iv);
00535 IMPORT_C int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
00536 const unsigned char *key, const unsigned char *iv);
00537 IMPORT_C int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
00538 int *outl, const unsigned char *in, int inl);
00539 IMPORT_C int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
00540 IMPORT_C int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
00541
00542 IMPORT_C int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
00543 const unsigned char *key, const unsigned char *iv);
00544 IMPORT_C int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
00545 const unsigned char *key, const unsigned char *iv);
00546 IMPORT_C int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
00547 int *outl, const unsigned char *in, int inl);
00548 IMPORT_C int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
00549 IMPORT_C int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
00550
00551 IMPORT_C int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
00552 const unsigned char *key,const unsigned char *iv,
00553 int enc);
00554 IMPORT_C int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
00555 const unsigned char *key,const unsigned char *iv,
00556 int enc);
00557 IMPORT_C int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
00558 int *outl, const unsigned char *in, int inl);
00559 IMPORT_C int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
00560 IMPORT_C int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
00561
00562 IMPORT_C int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
00563 EVP_PKEY *pkey);
00564
00565 IMPORT_C int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf,
00566 unsigned int siglen,EVP_PKEY *pkey);
00567
00568 IMPORT_C int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
00569 const unsigned char *ek, int ekl, const unsigned char *iv,
00570 EVP_PKEY *priv);
00571 IMPORT_C int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
00572
00573 IMPORT_C int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
00574 unsigned char **ek, int *ekl, unsigned char *iv,
00575 EVP_PKEY **pubk, int npubk);
00576 IMPORT_C int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
00577
00578 IMPORT_C void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
00579 IMPORT_C void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
00580 const unsigned char *in,int inl);
00581 IMPORT_C void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
00582 IMPORT_C int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
00583
00584 IMPORT_C void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
00585 IMPORT_C int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
00586 const unsigned char *in, int inl);
00587 IMPORT_C int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
00588 char *out, int *outl);
00589 IMPORT_C int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
00590
00591 IMPORT_C void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
00592 IMPORT_C int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
00593 IMPORT_C int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
00594 IMPORT_C int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
00595 IMPORT_C int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
00596 IMPORT_C int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
00597
00598 #ifndef OPENSSL_NO_BIO
00599 IMPORT_C BIO_METHOD *BIO_f_md(void);
00600 IMPORT_C BIO_METHOD *BIO_f_base64(void);
00601 IMPORT_C BIO_METHOD *BIO_f_cipher(void);
00602 IMPORT_C BIO_METHOD *BIO_f_reliable(void);
00603 IMPORT_C void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k,
00604 const unsigned char *i, int enc);
00605 #endif
00606
00607 IMPORT_C const EVP_MD *EVP_md_null(void);
00608 #ifndef OPENSSL_NO_MD2
00609 IMPORT_C const EVP_MD *EVP_md2(void);
00610 #endif
00611 #ifndef OPENSSL_NO_MD5
00612 IMPORT_C const EVP_MD *EVP_md5(void);
00613 #endif
00614 #ifndef OPENSSL_NO_SHA
00615 IMPORT_C const EVP_MD *EVP_sha(void);
00616 IMPORT_C const EVP_MD *EVP_sha1(void);
00617 IMPORT_C const EVP_MD *EVP_dss(void);
00618 IMPORT_C const EVP_MD *EVP_dss1(void);
00619 #endif
00620 IMPORT_C const EVP_CIPHER *EVP_enc_null(void);
00621 #ifndef OPENSSL_NO_DES
00622 IMPORT_C const EVP_CIPHER *EVP_des_ecb(void);
00623 IMPORT_C const EVP_CIPHER *EVP_des_ede(void);
00624 IMPORT_C const EVP_CIPHER *EVP_des_ede3(void);
00625 IMPORT_C const EVP_CIPHER *EVP_des_ede_ecb(void);
00626 IMPORT_C const EVP_CIPHER *EVP_des_ede3_ecb(void);
00627 IMPORT_C const EVP_CIPHER *EVP_des_cfb64(void);
00628 # define EVP_des_cfb EVP_des_cfb64
00629 IMPORT_C const EVP_CIPHER *EVP_des_cfb1(void);
00630 IMPORT_C const EVP_CIPHER *EVP_des_cfb8(void);
00631 IMPORT_C const EVP_CIPHER *EVP_des_ede_cfb64(void);
00632 # define EVP_des_ede_cfb EVP_des_ede_cfb64
00633 #if 0
00634 IMPORT_C const EVP_CIPHER *EVP_des_ede_cfb1(void);
00635 IMPORT_C const EVP_CIPHER *EVP_des_ede_cfb8(void);
00636 #endif
00637 IMPORT_C const EVP_CIPHER *EVP_des_ede3_cfb64(void);
00638 # define EVP_des_ede3_cfb EVP_des_ede3_cfb64
00639 IMPORT_C const EVP_CIPHER *EVP_des_ede3_cfb1(void);
00640 IMPORT_C const EVP_CIPHER *EVP_des_ede3_cfb8(void);
00641 IMPORT_C const EVP_CIPHER *EVP_des_ofb(void);
00642 IMPORT_C const EVP_CIPHER *EVP_des_ede_ofb(void);
00643 IMPORT_C const EVP_CIPHER *EVP_des_ede3_ofb(void);
00644 IMPORT_C const EVP_CIPHER *EVP_des_cbc(void);
00645 IMPORT_C const EVP_CIPHER *EVP_des_ede_cbc(void);
00646 IMPORT_C const EVP_CIPHER *EVP_des_ede3_cbc(void);
00647 IMPORT_C const EVP_CIPHER *EVP_desx_cbc(void);
00648
00649
00650 #if 0
00651 # ifdef OPENSSL_OPENBSD_DEV_CRYPTO
00652 IMPORT_C const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);
00653 IMPORT_C const EVP_CIPHER *EVP_dev_crypto_rc4(void);
00654 IMPORT_C const EVP_MD *EVP_dev_crypto_md5(void);
00655 # endif
00656 #endif
00657 #endif
00658 #ifndef OPENSSL_NO_RC4
00659 IMPORT_C const EVP_CIPHER *EVP_rc4(void);
00660 IMPORT_C const EVP_CIPHER *EVP_rc4_40(void);
00661 #endif
00662 #ifndef OPENSSL_NO_RC2
00663 IMPORT_C const EVP_CIPHER *EVP_rc2_ecb(void);
00664 IMPORT_C const EVP_CIPHER *EVP_rc2_cbc(void);
00665 IMPORT_C const EVP_CIPHER *EVP_rc2_40_cbc(void);
00666 IMPORT_C const EVP_CIPHER *EVP_rc2_64_cbc(void);
00667 IMPORT_C const EVP_CIPHER *EVP_rc2_cfb64(void);
00668 # define EVP_rc2_cfb EVP_rc2_cfb64
00669 IMPORT_C const EVP_CIPHER *EVP_rc2_ofb(void);
00670 #endif
00671 #ifndef OPENSSL_NO_AES
00672 IMPORT_C const EVP_CIPHER *EVP_aes_128_ecb(void);
00673 IMPORT_C const EVP_CIPHER *EVP_aes_128_cbc(void);
00674 IMPORT_C const EVP_CIPHER *EVP_aes_128_cfb1(void);
00675 IMPORT_C const EVP_CIPHER *EVP_aes_128_cfb8(void);
00676 IMPORT_C const EVP_CIPHER *EVP_aes_128_cfb128(void);
00677 # define EVP_aes_128_cfb EVP_aes_128_cfb128
00678 IMPORT_C const EVP_CIPHER *EVP_aes_128_ofb(void);
00679 #if 0
00680 IMPORT_C const EVP_CIPHER *EVP_aes_128_ctr(void);
00681 #endif
00682 IMPORT_C const EVP_CIPHER *EVP_aes_192_ecb(void);
00683 IMPORT_C const EVP_CIPHER *EVP_aes_192_cbc(void);
00684 IMPORT_C const EVP_CIPHER *EVP_aes_192_cfb1(void);
00685 IMPORT_C const EVP_CIPHER *EVP_aes_192_cfb8(void);
00686 IMPORT_C const EVP_CIPHER *EVP_aes_192_cfb128(void);
00687 # define EVP_aes_192_cfb EVP_aes_192_cfb128
00688 IMPORT_C const EVP_CIPHER *EVP_aes_192_ofb(void);
00689 #if 0
00690 IMPORT_C const EVP_CIPHER *EVP_aes_192_ctr(void);
00691 #endif
00692 IMPORT_C const EVP_CIPHER *EVP_aes_256_ecb(void);
00693 IMPORT_C const EVP_CIPHER *EVP_aes_256_cbc(void);
00694 IMPORT_C const EVP_CIPHER *EVP_aes_256_cfb1(void);
00695 IMPORT_C const EVP_CIPHER *EVP_aes_256_cfb8(void);
00696 IMPORT_C const EVP_CIPHER *EVP_aes_256_cfb128(void);
00697 # define EVP_aes_256_cfb EVP_aes_256_cfb128
00698 IMPORT_C const EVP_CIPHER *EVP_aes_256_ofb(void);
00699 #if 0
00700 IMPORT_C const EVP_CIPHER *EVP_aes_256_ctr(void);
00701 #endif
00702 #endif
00703
00704 IMPORT_C void OPENSSL_add_all_algorithms_noconf(void);
00705 IMPORT_C void OPENSSL_add_all_algorithms_conf(void);
00706
00707 #ifdef OPENSSL_LOAD_CONF
00708 #define OpenSSL_add_all_algorithms() \
00709 OPENSSL_add_all_algorithms_conf()
00710 #else
00711 #define OpenSSL_add_all_algorithms() \
00712 OPENSSL_add_all_algorithms_noconf()
00713 #endif
00714
00715 IMPORT_C void OpenSSL_add_all_ciphers(void);
00716 IMPORT_C void OpenSSL_add_all_digests(void);
00717 #define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
00718 #define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
00719 #define SSLeay_add_all_digests() OpenSSL_add_all_digests()
00720
00721 IMPORT_C int EVP_add_cipher(const EVP_CIPHER *cipher);
00722 IMPORT_C int EVP_add_digest(const EVP_MD *digest);
00723
00724 IMPORT_C const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
00725 IMPORT_C const EVP_MD *EVP_get_digestbyname(const char *name);
00726 IMPORT_C void EVP_cleanup(void);
00727
00728 IMPORT_C int EVP_PKEY_decrypt(unsigned char *dec_key,
00729 const unsigned char *enc_key,int enc_key_len,
00730 EVP_PKEY *private_key);
00731 IMPORT_C int EVP_PKEY_encrypt(unsigned char *enc_key,
00732 const unsigned char *key,int key_len,
00733 EVP_PKEY *pub_key);
00734 IMPORT_C int EVP_PKEY_type(int type);
00735 IMPORT_C int EVP_PKEY_bits(EVP_PKEY *pkey);
00736 IMPORT_C int EVP_PKEY_size(EVP_PKEY *pkey);
00737 IMPORT_C int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
00738
00739 #ifndef OPENSSL_NO_RSA
00740 struct rsa_st;
00741 IMPORT_C int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key);
00742 IMPORT_C struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
00743 #endif
00744 #ifndef OPENSSL_NO_DSA
00745 struct dsa_st;
00746 IMPORT_C int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key);
00747 IMPORT_C struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
00748 #endif
00749 #ifndef OPENSSL_NO_DH
00750 struct dh_st;
00751 IMPORT_C int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key);
00752 IMPORT_C struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
00753 #endif
00754
00755 IMPORT_C EVP_PKEY * EVP_PKEY_new(void);
00756 IMPORT_C void EVP_PKEY_free(EVP_PKEY *pkey);
00757
00758 IMPORT_C EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp,
00759 long length);
00760 IMPORT_C int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
00761
00762 IMPORT_C EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp,
00763 long length);
00764 IMPORT_C EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
00765 long length);
00766 IMPORT_C int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
00767
00768 IMPORT_C int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
00769 IMPORT_C int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
00770 IMPORT_C int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
00771 IMPORT_C int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
00772
00773 IMPORT_C int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
00774
00775 IMPORT_C int EVP_CIPHER_type(const EVP_CIPHER *ctx);
00776
00777
00778 IMPORT_C int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
00779 IMPORT_C int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
00780
00781
00782 IMPORT_C int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
00783 IMPORT_C int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
00784
00785
00786 IMPORT_C int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
00787 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
00788 int en_de);
00789 IMPORT_C int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
00790 const unsigned char *salt, int saltlen, int iter,
00791 int keylen, unsigned char *out);
00792 IMPORT_C int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
00793 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
00794 int en_de);
00795
00796 IMPORT_C void PKCS5_PBE_add(void);
00797
00798 IMPORT_C int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
00799 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
00800 IMPORT_C int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
00801 EVP_PBE_KEYGEN *keygen);
00802 IMPORT_C void EVP_PBE_cleanup(void);
00803
00804
00805
00806
00807
00808 IMPORT_C void ERR_load_EVP_strings(void);
00809
00810
00811
00812
00813 #define EVP_F_AES_INIT_KEY 133
00814 #define EVP_F_D2I_PKEY 100
00815 #define EVP_F_DSAPKEY2PKCS8 134
00816 #define EVP_F_DSA_PKEY2PKCS8 135
00817 #define EVP_F_ECDSA_PKEY2PKCS8 129
00818 #define EVP_F_ECKEY_PKEY2PKCS8 132
00819 #define EVP_F_EVP_CIPHERINIT_EX 123
00820 #define EVP_F_EVP_CIPHER_CTX_CTRL 124
00821 #define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
00822 #define EVP_F_EVP_DECRYPTFINAL_EX 101
00823 #define EVP_F_EVP_DIGESTINIT_EX 128
00824 #define EVP_F_EVP_ENCRYPTFINAL_EX 127
00825 #define EVP_F_EVP_MD_CTX_COPY_EX 110
00826 #define EVP_F_EVP_OPENINIT 102
00827 #define EVP_F_EVP_PBE_ALG_ADD 115
00828 #define EVP_F_EVP_PBE_CIPHERINIT 116
00829 #define EVP_F_EVP_PKCS82PKEY 111
00830 #define EVP_F_EVP_PKEY2PKCS8_BROKEN 113
00831 #define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
00832 #define EVP_F_EVP_PKEY_DECRYPT 104
00833 #define EVP_F_EVP_PKEY_ENCRYPT 105
00834 #define EVP_F_EVP_PKEY_GET1_DH 119
00835 #define EVP_F_EVP_PKEY_GET1_DSA 120
00836 #define EVP_F_EVP_PKEY_GET1_ECDSA 130
00837 #define EVP_F_EVP_PKEY_GET1_EC_KEY 131
00838 #define EVP_F_EVP_PKEY_GET1_RSA 121
00839 #define EVP_F_EVP_PKEY_NEW 106
00840 #define EVP_F_EVP_RIJNDAEL 126
00841 #define EVP_F_EVP_SIGNFINAL 107
00842 #define EVP_F_EVP_VERIFYFINAL 108
00843 #define EVP_F_PKCS5_PBE_KEYIVGEN 117
00844 #define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118
00845 #define EVP_F_PKCS8_SET_BROKEN 112
00846 #define EVP_F_RC2_MAGIC_TO_METH 109
00847 #define EVP_F_RC5_CTRL 125
00848
00849
00850 #define EVP_R_AES_KEY_SETUP_FAILED 143
00851 #define EVP_R_ASN1_LIB 140
00852 #define EVP_R_BAD_BLOCK_LENGTH 136
00853 #define EVP_R_BAD_DECRYPT 100
00854 #define EVP_R_BAD_KEY_LENGTH 137
00855 #define EVP_R_BN_DECODE_ERROR 112
00856 #define EVP_R_BN_PUBKEY_ERROR 113
00857 #define EVP_R_CIPHER_PARAMETER_ERROR 122
00858 #define EVP_R_CTRL_NOT_IMPLEMENTED 132
00859 #define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133
00860 #define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138
00861 #define EVP_R_DECODE_ERROR 114
00862 #define EVP_R_DIFFERENT_KEY_TYPES 101
00863 #define EVP_R_ENCODE_ERROR 115
00864 #define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
00865 #define EVP_R_EXPECTING_AN_RSA_KEY 127
00866 #define EVP_R_EXPECTING_A_DH_KEY 128
00867 #define EVP_R_EXPECTING_A_DSA_KEY 129
00868 #define EVP_R_EXPECTING_A_ECDSA_KEY 141
00869 #define EVP_R_EXPECTING_A_EC_KEY 142
00870 #define EVP_R_INITIALIZATION_ERROR 134
00871 #define EVP_R_INPUT_NOT_INITIALIZED 111
00872 #define EVP_R_INVALID_KEY_LENGTH 130
00873 #define EVP_R_IV_TOO_LARGE 102
00874 #define EVP_R_KEYGEN_FAILURE 120
00875 #define EVP_R_MISSING_PARAMETERS 103
00876 #define EVP_R_NO_CIPHER_SET 131
00877 #define EVP_R_NO_DIGEST_SET 139
00878 #define EVP_R_NO_DSA_PARAMETERS 116
00879 #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
00880 #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
00881 #define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117
00882 #define EVP_R_PUBLIC_KEY_NOT_RSA 106
00883 #define EVP_R_UNKNOWN_PBE_ALGORITHM 121
00884 #define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135
00885 #define EVP_R_UNSUPPORTED_CIPHER 107
00886 #define EVP_R_UNSUPPORTED_KEYLENGTH 123
00887 #define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124
00888 #define EVP_R_UNSUPPORTED_KEY_SIZE 108
00889 #define EVP_R_UNSUPPORTED_PRF 125
00890 #define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118
00891 #define EVP_R_UNSUPPORTED_SALT_TYPE 126
00892 #define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109
00893 #define EVP_R_WRONG_PUBLIC_KEY_TYPE 110
00894
00895 #ifdef __cplusplus
00896 }
00897 #endif
00898 #endif