diff options
author | markus <> | 2002-09-05 12:51:52 +0000 |
---|---|---|
committer | markus <> | 2002-09-05 12:51:52 +0000 |
commit | 5514995a9d5ed91db089875adb509c7781357c0e (patch) | |
tree | 2484410a46ba6c05ef94c253da36fbceef990b64 /src/lib/libcrypto/evp | |
parent | fd9566423b542798f5c8b06e68101a9ea5bb9885 (diff) | |
download | openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.gz openbsd-5514995a9d5ed91db089875adb509c7781357c0e.tar.bz2 openbsd-5514995a9d5ed91db089875adb509c7781357c0e.zip |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/evp')
-rw-r--r-- | src/lib/libcrypto/evp/bio_ok.c | 97 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/c_allc.c | 45 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/c_alld.c | 19 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/e_dsa.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/e_rc5.c | 65 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/evp_test.c | 145 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/evptests.txt | 125 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/m_md2.c | 32 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/m_mdc2.c | 31 | ||||
-rw-r--r-- | src/lib/libcrypto/evp/m_sha.c | 31 |
10 files changed, 412 insertions, 184 deletions
diff --git a/src/lib/libcrypto/evp/bio_ok.c b/src/lib/libcrypto/evp/bio_ok.c index 101275d648..3cbc6e7848 100644 --- a/src/lib/libcrypto/evp/bio_ok.c +++ b/src/lib/libcrypto/evp/bio_ok.c | |||
@@ -67,7 +67,7 @@ | |||
67 | and everything was OK. BUT if user types wrong password | 67 | and everything was OK. BUT if user types wrong password |
68 | BIO_f_cipher outputs only garbage and my function crashes. Yes | 68 | BIO_f_cipher outputs only garbage and my function crashes. Yes |
69 | I can and I should fix my function, but BIO_f_cipher is | 69 | I can and I should fix my function, but BIO_f_cipher is |
70 | easy way to add encryption support to many exisiting applications | 70 | easy way to add encryption support to many existing applications |
71 | and it's hard to debug and fix them all. | 71 | and it's hard to debug and fix them all. |
72 | 72 | ||
73 | So I wanted another BIO which would catch the incorrect passwords and | 73 | So I wanted another BIO which would catch the incorrect passwords and |
@@ -80,10 +80,10 @@ | |||
80 | 1) you must somehow separate checksum from actual data. | 80 | 1) you must somehow separate checksum from actual data. |
81 | 2) you need lot's of memory when reading the file, because you | 81 | 2) you need lot's of memory when reading the file, because you |
82 | must read to the end of the file and verify the checksum before | 82 | must read to the end of the file and verify the checksum before |
83 | leting the application to read the data. | 83 | letting the application to read the data. |
84 | 84 | ||
85 | BIO_f_reliable tries to solve both problems, so that you can | 85 | BIO_f_reliable tries to solve both problems, so that you can |
86 | read and write arbitraly long streams using only fixed amount | 86 | read and write arbitrary long streams using only fixed amount |
87 | of memory. | 87 | of memory. |
88 | 88 | ||
89 | BIO_f_reliable splits data stream into blocks. Each block is prefixed | 89 | BIO_f_reliable splits data stream into blocks. Each block is prefixed |
@@ -91,7 +91,7 @@ | |||
91 | several Kbytes of memory to buffer single block before verifying | 91 | several Kbytes of memory to buffer single block before verifying |
92 | it's digest. | 92 | it's digest. |
93 | 93 | ||
94 | BIO_f_reliable goes futher and adds several important capabilities: | 94 | BIO_f_reliable goes further and adds several important capabilities: |
95 | 95 | ||
96 | 1) the digest of the block is computed over the whole stream | 96 | 1) the digest of the block is computed over the whole stream |
97 | -- so nobody can rearrange the blocks or remove or replace them. | 97 | -- so nobody can rearrange the blocks or remove or replace them. |
@@ -110,7 +110,7 @@ | |||
110 | and then compare the digest output. | 110 | and then compare the digest output. |
111 | 111 | ||
112 | Bad things: BIO_f_reliable knows what's going on in EVP_Digest. I | 112 | Bad things: BIO_f_reliable knows what's going on in EVP_Digest. I |
113 | initialy wrote and tested this code on x86 machine and wrote the | 113 | initially wrote and tested this code on x86 machine and wrote the |
114 | digests out in machine-dependent order :( There are people using | 114 | digests out in machine-dependent order :( There are people using |
115 | this code and I cannot change this easily without making existing | 115 | this code and I cannot change this easily without making existing |
116 | data files unreadable. | 116 | data files unreadable. |
@@ -125,11 +125,13 @@ | |||
125 | #include <openssl/evp.h> | 125 | #include <openssl/evp.h> |
126 | #include <openssl/rand.h> | 126 | #include <openssl/rand.h> |
127 | 127 | ||
128 | static int ok_write(BIO *h,char *buf,int num); | 128 | static int ok_write(BIO *h, const char *buf, int num); |
129 | static int ok_read(BIO *h,char *buf,int size); | 129 | static int ok_read(BIO *h, char *buf, int size); |
130 | static long ok_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 130 | static long ok_ctrl(BIO *h, int cmd, long arg1, void *arg2); |
131 | static int ok_new(BIO *h); | 131 | static int ok_new(BIO *h); |
132 | static int ok_free(BIO *data); | 132 | static int ok_free(BIO *data); |
133 | static long ok_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); | ||
134 | |||
133 | static void sig_out(BIO* b); | 135 | static void sig_out(BIO* b); |
134 | static void sig_in(BIO* b); | 136 | static void sig_in(BIO* b); |
135 | static void block_out(BIO* b); | 137 | static void block_out(BIO* b); |
@@ -160,7 +162,7 @@ typedef struct ok_struct | |||
160 | EVP_MD_CTX md; | 162 | EVP_MD_CTX md; |
161 | int blockout; /* output block is ready */ | 163 | int blockout; /* output block is ready */ |
162 | int sigio; /* must process signature */ | 164 | int sigio; /* must process signature */ |
163 | char buf[IOBS]; | 165 | unsigned char buf[IOBS]; |
164 | } BIO_OK_CTX; | 166 | } BIO_OK_CTX; |
165 | 167 | ||
166 | static BIO_METHOD methods_ok= | 168 | static BIO_METHOD methods_ok= |
@@ -173,6 +175,7 @@ static BIO_METHOD methods_ok= | |||
173 | ok_ctrl, | 175 | ok_ctrl, |
174 | ok_new, | 176 | ok_new, |
175 | ok_free, | 177 | ok_free, |
178 | ok_callback_ctrl, | ||
176 | }; | 179 | }; |
177 | 180 | ||
178 | BIO_METHOD *BIO_f_reliable(void) | 181 | BIO_METHOD *BIO_f_reliable(void) |
@@ -184,7 +187,7 @@ static int ok_new(BIO *bi) | |||
184 | { | 187 | { |
185 | BIO_OK_CTX *ctx; | 188 | BIO_OK_CTX *ctx; |
186 | 189 | ||
187 | ctx=(BIO_OK_CTX *)Malloc(sizeof(BIO_OK_CTX)); | 190 | ctx=(BIO_OK_CTX *)OPENSSL_malloc(sizeof(BIO_OK_CTX)); |
188 | if (ctx == NULL) return(0); | 191 | if (ctx == NULL) return(0); |
189 | 192 | ||
190 | ctx->buf_len=0; | 193 | ctx->buf_len=0; |
@@ -196,6 +199,8 @@ static int ok_new(BIO *bi) | |||
196 | ctx->blockout= 0; | 199 | ctx->blockout= 0; |
197 | ctx->sigio=1; | 200 | ctx->sigio=1; |
198 | 201 | ||
202 | EVP_MD_CTX_init(&ctx->md); | ||
203 | |||
199 | bi->init=0; | 204 | bi->init=0; |
200 | bi->ptr=(char *)ctx; | 205 | bi->ptr=(char *)ctx; |
201 | bi->flags=0; | 206 | bi->flags=0; |
@@ -205,8 +210,9 @@ static int ok_new(BIO *bi) | |||
205 | static int ok_free(BIO *a) | 210 | static int ok_free(BIO *a) |
206 | { | 211 | { |
207 | if (a == NULL) return(0); | 212 | if (a == NULL) return(0); |
213 | EVP_MD_CTX_cleanup(&((BIO_OK_CTX *)a->ptr)->md); | ||
208 | memset(a->ptr,0,sizeof(BIO_OK_CTX)); | 214 | memset(a->ptr,0,sizeof(BIO_OK_CTX)); |
209 | Free(a->ptr); | 215 | OPENSSL_free(a->ptr); |
210 | a->ptr=NULL; | 216 | a->ptr=NULL; |
211 | a->init=0; | 217 | a->init=0; |
212 | a->flags=0; | 218 | a->flags=0; |
@@ -284,7 +290,7 @@ static int ok_read(BIO *b, char *out, int outl) | |||
284 | return(ret); | 290 | return(ret); |
285 | } | 291 | } |
286 | 292 | ||
287 | static int ok_write(BIO *b, char *in, int inl) | 293 | static int ok_write(BIO *b, const char *in, int inl) |
288 | { | 294 | { |
289 | int ret=0,n,i; | 295 | int ret=0,n,i; |
290 | BIO_OK_CTX *ctx; | 296 | BIO_OK_CTX *ctx; |
@@ -342,7 +348,7 @@ static int ok_write(BIO *b, char *in, int inl) | |||
342 | return(ret); | 348 | return(ret); |
343 | } | 349 | } |
344 | 350 | ||
345 | static long ok_ctrl(BIO *b, int cmd, long num, char *ptr) | 351 | static long ok_ctrl(BIO *b, int cmd, long num, void *ptr) |
346 | { | 352 | { |
347 | BIO_OK_CTX *ctx; | 353 | BIO_OK_CTX *ctx; |
348 | EVP_MD *md; | 354 | EVP_MD *md; |
@@ -350,7 +356,7 @@ static long ok_ctrl(BIO *b, int cmd, long num, char *ptr) | |||
350 | long ret=1; | 356 | long ret=1; |
351 | int i; | 357 | int i; |
352 | 358 | ||
353 | ctx=(BIO_OK_CTX *)b->ptr; | 359 | ctx=b->ptr; |
354 | 360 | ||
355 | switch (cmd) | 361 | switch (cmd) |
356 | { | 362 | { |
@@ -408,14 +414,14 @@ static long ok_ctrl(BIO *b, int cmd, long num, char *ptr) | |||
408 | ret=(long)ctx->cont; | 414 | ret=(long)ctx->cont; |
409 | break; | 415 | break; |
410 | case BIO_C_SET_MD: | 416 | case BIO_C_SET_MD: |
411 | md=(EVP_MD *)ptr; | 417 | md=ptr; |
412 | EVP_DigestInit(&(ctx->md),md); | 418 | EVP_DigestInit_ex(&ctx->md, md, NULL); |
413 | b->init=1; | 419 | b->init=1; |
414 | break; | 420 | break; |
415 | case BIO_C_GET_MD: | 421 | case BIO_C_GET_MD: |
416 | if (b->init) | 422 | if (b->init) |
417 | { | 423 | { |
418 | ppmd=(const EVP_MD **)ptr; | 424 | ppmd=ptr; |
419 | *ppmd=ctx->md.digest; | 425 | *ppmd=ctx->md.digest; |
420 | } | 426 | } |
421 | else | 427 | else |
@@ -428,6 +434,20 @@ static long ok_ctrl(BIO *b, int cmd, long num, char *ptr) | |||
428 | return(ret); | 434 | return(ret); |
429 | } | 435 | } |
430 | 436 | ||
437 | static long ok_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) | ||
438 | { | ||
439 | long ret=1; | ||
440 | |||
441 | if (b->next_bio == NULL) return(0); | ||
442 | switch (cmd) | ||
443 | { | ||
444 | default: | ||
445 | ret=BIO_callback_ctrl(b->next_bio,cmd,fp); | ||
446 | break; | ||
447 | } | ||
448 | return(ret); | ||
449 | } | ||
450 | |||
431 | static void longswap(void *_ptr, int len) | 451 | static void longswap(void *_ptr, int len) |
432 | { | 452 | { |
433 | #ifndef L_ENDIAN | 453 | #ifndef L_ENDIAN |
@@ -445,19 +465,22 @@ static void sig_out(BIO* b) | |||
445 | BIO_OK_CTX *ctx; | 465 | BIO_OK_CTX *ctx; |
446 | EVP_MD_CTX *md; | 466 | EVP_MD_CTX *md; |
447 | 467 | ||
448 | ctx=(BIO_OK_CTX *)b->ptr; | 468 | ctx=b->ptr; |
449 | md= &(ctx->md); | 469 | md=&ctx->md; |
450 | 470 | ||
451 | if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return; | 471 | if(ctx->buf_len+ 2* md->digest->md_size > OK_BLOCK_SIZE) return; |
452 | 472 | ||
453 | EVP_DigestInit(md, md->digest); | 473 | EVP_DigestInit_ex(md, md->digest, NULL); |
454 | RAND_bytes(&(md->md.base[0]), md->digest->md_size); | 474 | /* FIXME: there's absolutely no guarantee this makes any sense at all, |
455 | memcpy(&(ctx->buf[ctx->buf_len]), &(md->md.base[0]), md->digest->md_size); | 475 | * particularly now EVP_MD_CTX has been restructured. |
476 | */ | ||
477 | RAND_pseudo_bytes(md->md_data, md->digest->md_size); | ||
478 | memcpy(&(ctx->buf[ctx->buf_len]), md->md_data, md->digest->md_size); | ||
456 | longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size); | 479 | longswap(&(ctx->buf[ctx->buf_len]), md->digest->md_size); |
457 | ctx->buf_len+= md->digest->md_size; | 480 | ctx->buf_len+= md->digest->md_size; |
458 | 481 | ||
459 | EVP_DigestUpdate(md, (unsigned char*)WELLKNOWN, strlen(WELLKNOWN)); | 482 | EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)); |
460 | md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0])); | 483 | EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL); |
461 | ctx->buf_len+= md->digest->md_size; | 484 | ctx->buf_len+= md->digest->md_size; |
462 | ctx->blockout= 1; | 485 | ctx->blockout= 1; |
463 | ctx->sigio= 0; | 486 | ctx->sigio= 0; |
@@ -470,18 +493,18 @@ static void sig_in(BIO* b) | |||
470 | unsigned char tmp[EVP_MAX_MD_SIZE]; | 493 | unsigned char tmp[EVP_MAX_MD_SIZE]; |
471 | int ret= 0; | 494 | int ret= 0; |
472 | 495 | ||
473 | ctx=(BIO_OK_CTX *)b->ptr; | 496 | ctx=b->ptr; |
474 | md= &(ctx->md); | 497 | md=&ctx->md; |
475 | 498 | ||
476 | if(ctx->buf_len- ctx->buf_off < 2* md->digest->md_size) return; | 499 | if(ctx->buf_len- ctx->buf_off < 2* md->digest->md_size) return; |
477 | 500 | ||
478 | EVP_DigestInit(md, md->digest); | 501 | EVP_DigestInit_ex(md, md->digest, NULL); |
479 | memcpy(&(md->md.base[0]), &(ctx->buf[ctx->buf_off]), md->digest->md_size); | 502 | memcpy(md->md_data, &(ctx->buf[ctx->buf_off]), md->digest->md_size); |
480 | longswap(&(md->md.base[0]), md->digest->md_size); | 503 | longswap(md->md_data, md->digest->md_size); |
481 | ctx->buf_off+= md->digest->md_size; | 504 | ctx->buf_off+= md->digest->md_size; |
482 | 505 | ||
483 | EVP_DigestUpdate(md, (unsigned char*)WELLKNOWN, strlen(WELLKNOWN)); | 506 | EVP_DigestUpdate(md, WELLKNOWN, strlen(WELLKNOWN)); |
484 | md->digest->final(tmp, &(md->md.base[0])); | 507 | EVP_DigestFinal_ex(md, tmp, NULL); |
485 | ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0; | 508 | ret= memcmp(&(ctx->buf[ctx->buf_off]), tmp, md->digest->md_size) == 0; |
486 | ctx->buf_off+= md->digest->md_size; | 509 | ctx->buf_off+= md->digest->md_size; |
487 | if(ret == 1) | 510 | if(ret == 1) |
@@ -506,15 +529,15 @@ static void block_out(BIO* b) | |||
506 | EVP_MD_CTX *md; | 529 | EVP_MD_CTX *md; |
507 | unsigned long tl; | 530 | unsigned long tl; |
508 | 531 | ||
509 | ctx=(BIO_OK_CTX *)b->ptr; | 532 | ctx=b->ptr; |
510 | md= &(ctx->md); | 533 | md=&ctx->md; |
511 | 534 | ||
512 | tl= ctx->buf_len- OK_BLOCK_BLOCK; | 535 | tl= ctx->buf_len- OK_BLOCK_BLOCK; |
513 | tl= swapem(tl); | 536 | tl= swapem(tl); |
514 | memcpy(ctx->buf, &tl, OK_BLOCK_BLOCK); | 537 | memcpy(ctx->buf, &tl, OK_BLOCK_BLOCK); |
515 | tl= swapem(tl); | 538 | tl= swapem(tl); |
516 | EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); | 539 | EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); |
517 | md->digest->final(&(ctx->buf[ctx->buf_len]), &(md->md.base[0])); | 540 | EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL); |
518 | ctx->buf_len+= md->digest->md_size; | 541 | ctx->buf_len+= md->digest->md_size; |
519 | ctx->blockout= 1; | 542 | ctx->blockout= 1; |
520 | } | 543 | } |
@@ -526,15 +549,15 @@ static void block_in(BIO* b) | |||
526 | long tl= 0; | 549 | long tl= 0; |
527 | unsigned char tmp[EVP_MAX_MD_SIZE]; | 550 | unsigned char tmp[EVP_MAX_MD_SIZE]; |
528 | 551 | ||
529 | ctx=(BIO_OK_CTX *)b->ptr; | 552 | ctx=b->ptr; |
530 | md= &(ctx->md); | 553 | md=&ctx->md; |
531 | 554 | ||
532 | memcpy(&tl, ctx->buf, OK_BLOCK_BLOCK); | 555 | memcpy(&tl, ctx->buf, OK_BLOCK_BLOCK); |
533 | tl= swapem(tl); | 556 | tl= swapem(tl); |
534 | if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return; | 557 | if (ctx->buf_len < tl+ OK_BLOCK_BLOCK+ md->digest->md_size) return; |
535 | 558 | ||
536 | EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); | 559 | EVP_DigestUpdate(md, (unsigned char*) &(ctx->buf[OK_BLOCK_BLOCK]), tl); |
537 | md->digest->final(tmp, &(md->md.base[0])); | 560 | EVP_DigestFinal_ex(md, tmp, NULL); |
538 | if(memcmp(&(ctx->buf[tl+ OK_BLOCK_BLOCK]), tmp, md->digest->md_size) == 0) | 561 | if(memcmp(&(ctx->buf[tl+ OK_BLOCK_BLOCK]), tmp, md->digest->md_size) == 0) |
539 | { | 562 | { |
540 | /* there might be parts from next block lurking around ! */ | 563 | /* there might be parts from next block lurking around ! */ |
diff --git a/src/lib/libcrypto/evp/c_allc.c b/src/lib/libcrypto/evp/c_allc.c index f24d3756c9..341a958fd4 100644 --- a/src/lib/libcrypto/evp/c_allc.c +++ b/src/lib/libcrypto/evp/c_allc.c | |||
@@ -64,7 +64,8 @@ | |||
64 | 64 | ||
65 | void OpenSSL_add_all_ciphers(void) | 65 | void OpenSSL_add_all_ciphers(void) |
66 | { | 66 | { |
67 | #ifndef NO_DES | 67 | |
68 | #ifndef OPENSSL_NO_DES | ||
68 | EVP_add_cipher(EVP_des_cfb()); | 69 | EVP_add_cipher(EVP_des_cfb()); |
69 | EVP_add_cipher(EVP_des_ede_cfb()); | 70 | EVP_add_cipher(EVP_des_ede_cfb()); |
70 | EVP_add_cipher(EVP_des_ede3_cfb()); | 71 | EVP_add_cipher(EVP_des_ede3_cfb()); |
@@ -90,12 +91,12 @@ void OpenSSL_add_all_ciphers(void) | |||
90 | EVP_add_cipher(EVP_des_ede3()); | 91 | EVP_add_cipher(EVP_des_ede3()); |
91 | #endif | 92 | #endif |
92 | 93 | ||
93 | #ifndef NO_RC4 | 94 | #ifndef OPENSSL_NO_RC4 |
94 | EVP_add_cipher(EVP_rc4()); | 95 | EVP_add_cipher(EVP_rc4()); |
95 | EVP_add_cipher(EVP_rc4_40()); | 96 | EVP_add_cipher(EVP_rc4_40()); |
96 | #endif | 97 | #endif |
97 | 98 | ||
98 | #ifndef NO_IDEA | 99 | #ifndef OPENSSL_NO_IDEA |
99 | EVP_add_cipher(EVP_idea_ecb()); | 100 | EVP_add_cipher(EVP_idea_ecb()); |
100 | EVP_add_cipher(EVP_idea_cfb()); | 101 | EVP_add_cipher(EVP_idea_cfb()); |
101 | EVP_add_cipher(EVP_idea_ofb()); | 102 | EVP_add_cipher(EVP_idea_ofb()); |
@@ -104,7 +105,7 @@ void OpenSSL_add_all_ciphers(void) | |||
104 | EVP_add_cipher_alias(SN_idea_cbc,"idea"); | 105 | EVP_add_cipher_alias(SN_idea_cbc,"idea"); |
105 | #endif | 106 | #endif |
106 | 107 | ||
107 | #ifndef NO_RC2 | 108 | #ifndef OPENSSL_NO_RC2 |
108 | EVP_add_cipher(EVP_rc2_ecb()); | 109 | EVP_add_cipher(EVP_rc2_ecb()); |
109 | EVP_add_cipher(EVP_rc2_cfb()); | 110 | EVP_add_cipher(EVP_rc2_cfb()); |
110 | EVP_add_cipher(EVP_rc2_ofb()); | 111 | EVP_add_cipher(EVP_rc2_ofb()); |
@@ -115,7 +116,7 @@ void OpenSSL_add_all_ciphers(void) | |||
115 | EVP_add_cipher_alias(SN_rc2_cbc,"rc2"); | 116 | EVP_add_cipher_alias(SN_rc2_cbc,"rc2"); |
116 | #endif | 117 | #endif |
117 | 118 | ||
118 | #ifndef NO_BF | 119 | #ifndef OPENSSL_NO_BF |
119 | EVP_add_cipher(EVP_bf_ecb()); | 120 | EVP_add_cipher(EVP_bf_ecb()); |
120 | EVP_add_cipher(EVP_bf_cfb()); | 121 | EVP_add_cipher(EVP_bf_cfb()); |
121 | EVP_add_cipher(EVP_bf_ofb()); | 122 | EVP_add_cipher(EVP_bf_ofb()); |
@@ -125,7 +126,7 @@ void OpenSSL_add_all_ciphers(void) | |||
125 | EVP_add_cipher_alias(SN_bf_cbc,"blowfish"); | 126 | EVP_add_cipher_alias(SN_bf_cbc,"blowfish"); |
126 | #endif | 127 | #endif |
127 | 128 | ||
128 | #ifndef NO_CAST | 129 | #ifndef OPENSSL_NO_CAST |
129 | EVP_add_cipher(EVP_cast5_ecb()); | 130 | EVP_add_cipher(EVP_cast5_ecb()); |
130 | EVP_add_cipher(EVP_cast5_cfb()); | 131 | EVP_add_cipher(EVP_cast5_cfb()); |
131 | EVP_add_cipher(EVP_cast5_ofb()); | 132 | EVP_add_cipher(EVP_cast5_ofb()); |
@@ -136,7 +137,7 @@ void OpenSSL_add_all_ciphers(void) | |||
136 | EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc"); | 137 | EVP_add_cipher_alias(SN_cast5_cbc,"cast-cbc"); |
137 | #endif | 138 | #endif |
138 | 139 | ||
139 | #ifndef NO_RC5 | 140 | #ifndef OPENSSL_NO_RC5 |
140 | EVP_add_cipher(EVP_rc5_32_12_16_ecb()); | 141 | EVP_add_cipher(EVP_rc5_32_12_16_ecb()); |
141 | EVP_add_cipher(EVP_rc5_32_12_16_cfb()); | 142 | EVP_add_cipher(EVP_rc5_32_12_16_cfb()); |
142 | EVP_add_cipher(EVP_rc5_32_12_16_ofb()); | 143 | EVP_add_cipher(EVP_rc5_32_12_16_ofb()); |
@@ -144,6 +145,36 @@ void OpenSSL_add_all_ciphers(void) | |||
144 | EVP_add_cipher_alias(SN_rc5_cbc,"rc5"); | 145 | EVP_add_cipher_alias(SN_rc5_cbc,"rc5"); |
145 | EVP_add_cipher_alias(SN_rc5_cbc,"RC5"); | 146 | EVP_add_cipher_alias(SN_rc5_cbc,"RC5"); |
146 | #endif | 147 | #endif |
148 | |||
149 | #ifndef OPENSSL_NO_AES | ||
150 | EVP_add_cipher(EVP_aes_128_ecb()); | ||
151 | EVP_add_cipher(EVP_aes_128_cbc()); | ||
152 | EVP_add_cipher(EVP_aes_128_cfb()); | ||
153 | EVP_add_cipher(EVP_aes_128_ofb()); | ||
154 | #if 0 | ||
155 | EVP_add_cipher(EVP_aes_128_ctr()); | ||
156 | #endif | ||
157 | EVP_add_cipher_alias(SN_aes_128_cbc,"AES128"); | ||
158 | EVP_add_cipher_alias(SN_aes_128_cbc,"aes128"); | ||
159 | EVP_add_cipher(EVP_aes_192_ecb()); | ||
160 | EVP_add_cipher(EVP_aes_192_cbc()); | ||
161 | EVP_add_cipher(EVP_aes_192_cfb()); | ||
162 | EVP_add_cipher(EVP_aes_192_ofb()); | ||
163 | #if 0 | ||
164 | EVP_add_cipher(EVP_aes_192_ctr()); | ||
165 | #endif | ||
166 | EVP_add_cipher_alias(SN_aes_192_cbc,"AES192"); | ||
167 | EVP_add_cipher_alias(SN_aes_192_cbc,"aes192"); | ||
168 | EVP_add_cipher(EVP_aes_256_ecb()); | ||
169 | EVP_add_cipher(EVP_aes_256_cbc()); | ||
170 | EVP_add_cipher(EVP_aes_256_cfb()); | ||
171 | EVP_add_cipher(EVP_aes_256_ofb()); | ||
172 | #if 0 | ||
173 | EVP_add_cipher(EVP_aes_256_ctr()); | ||
174 | #endif | ||
175 | EVP_add_cipher_alias(SN_aes_256_cbc,"AES256"); | ||
176 | EVP_add_cipher_alias(SN_aes_256_cbc,"aes256"); | ||
177 | #endif | ||
147 | PKCS12_PBE_add(); | 178 | PKCS12_PBE_add(); |
148 | PKCS5_PBE_add(); | 179 | PKCS5_PBE_add(); |
149 | } | 180 | } |
diff --git a/src/lib/libcrypto/evp/c_alld.c b/src/lib/libcrypto/evp/c_alld.c index febe51a3ee..be91cdb037 100644 --- a/src/lib/libcrypto/evp/c_alld.c +++ b/src/lib/libcrypto/evp/c_alld.c | |||
@@ -64,35 +64,38 @@ | |||
64 | 64 | ||
65 | void OpenSSL_add_all_digests(void) | 65 | void OpenSSL_add_all_digests(void) |
66 | { | 66 | { |
67 | #ifndef NO_MD2 | 67 | #ifndef OPENSSL_NO_MD2 |
68 | EVP_add_digest(EVP_md2()); | 68 | EVP_add_digest(EVP_md2()); |
69 | #endif | 69 | #endif |
70 | #ifndef NO_MD5 | 70 | #ifndef OPENSSL_NO_MD4 |
71 | EVP_add_digest(EVP_md4()); | ||
72 | #endif | ||
73 | #ifndef OPENSSL_NO_MD5 | ||
71 | EVP_add_digest(EVP_md5()); | 74 | EVP_add_digest(EVP_md5()); |
72 | EVP_add_digest_alias(SN_md5,"ssl2-md5"); | 75 | EVP_add_digest_alias(SN_md5,"ssl2-md5"); |
73 | EVP_add_digest_alias(SN_md5,"ssl3-md5"); | 76 | EVP_add_digest_alias(SN_md5,"ssl3-md5"); |
74 | #endif | 77 | #endif |
75 | #ifndef NO_SHA | 78 | #ifndef OPENSSL_NO_SHA |
76 | EVP_add_digest(EVP_sha()); | 79 | EVP_add_digest(EVP_sha()); |
77 | #ifndef NO_DSA | 80 | #ifndef OPENSSL_NO_DSA |
78 | EVP_add_digest(EVP_dss()); | 81 | EVP_add_digest(EVP_dss()); |
79 | #endif | 82 | #endif |
80 | #endif | 83 | #endif |
81 | #ifndef NO_SHA | 84 | #ifndef OPENSSL_NO_SHA |
82 | EVP_add_digest(EVP_sha1()); | 85 | EVP_add_digest(EVP_sha1()); |
83 | EVP_add_digest_alias(SN_sha1,"ssl3-sha1"); | 86 | EVP_add_digest_alias(SN_sha1,"ssl3-sha1"); |
84 | EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA); | 87 | EVP_add_digest_alias(SN_sha1WithRSAEncryption,SN_sha1WithRSA); |
85 | #ifndef NO_DSA | 88 | #ifndef OPENSSL_NO_DSA |
86 | EVP_add_digest(EVP_dss1()); | 89 | EVP_add_digest(EVP_dss1()); |
87 | EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2); | 90 | EVP_add_digest_alias(SN_dsaWithSHA1,SN_dsaWithSHA1_2); |
88 | EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1"); | 91 | EVP_add_digest_alias(SN_dsaWithSHA1,"DSS1"); |
89 | EVP_add_digest_alias(SN_dsaWithSHA1,"dss1"); | 92 | EVP_add_digest_alias(SN_dsaWithSHA1,"dss1"); |
90 | #endif | 93 | #endif |
91 | #endif | 94 | #endif |
92 | #if !defined(NO_MDC2) && !defined(NO_DES) | 95 | #if !defined(OPENSSL_NO_MDC2) && !defined(OPENSSL_NO_DES) |
93 | EVP_add_digest(EVP_mdc2()); | 96 | EVP_add_digest(EVP_mdc2()); |
94 | #endif | 97 | #endif |
95 | #ifndef NO_RIPEMD | 98 | #ifndef OPENSSL_NO_RIPEMD |
96 | EVP_add_digest(EVP_ripemd160()); | 99 | EVP_add_digest(EVP_ripemd160()); |
97 | EVP_add_digest_alias(SN_ripemd160,"ripemd"); | 100 | EVP_add_digest_alias(SN_ripemd160,"ripemd"); |
98 | EVP_add_digest_alias(SN_ripemd160,"rmd160"); | 101 | EVP_add_digest_alias(SN_ripemd160,"rmd160"); |
diff --git a/src/lib/libcrypto/evp/e_dsa.c b/src/lib/libcrypto/evp/e_dsa.c index 6715c3e95e..b96f2738b3 100644 --- a/src/lib/libcrypto/evp/e_dsa.c +++ b/src/lib/libcrypto/evp/e_dsa.c | |||
@@ -58,9 +58,9 @@ | |||
58 | 58 | ||
59 | #include <stdio.h> | 59 | #include <stdio.h> |
60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
61 | #include "evp.h" | 61 | #include <openssl/evp.h> |
62 | #include "objects.h" | 62 | #include <openssl/objects.h> |
63 | #include "x509.h" | 63 | #include <openssl/x509.h> |
64 | 64 | ||
65 | static EVP_PKEY_METHOD dss_method= | 65 | static EVP_PKEY_METHOD dss_method= |
66 | { | 66 | { |
diff --git a/src/lib/libcrypto/evp/e_rc5.c b/src/lib/libcrypto/evp/e_rc5.c index 5885f1826b..3c7713b181 100644 --- a/src/lib/libcrypto/evp/e_rc5.c +++ b/src/lib/libcrypto/evp/e_rc5.c | |||
@@ -56,62 +56,69 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef NO_RC5 | 59 | #ifndef OPENSSL_NO_RC5 |
60 | 60 | ||
61 | #include <stdio.h> | 61 | #include <stdio.h> |
62 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
63 | #include <openssl/evp.h> | 63 | #include <openssl/evp.h> |
64 | #include <openssl/objects.h> | 64 | #include <openssl/objects.h> |
65 | #include "evp_locl.h" | 65 | #include "evp_locl.h" |
66 | #include <openssl/rc5.h> | ||
66 | 67 | ||
67 | static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 68 | static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
68 | const unsigned char *iv,int enc); | 69 | const unsigned char *iv,int enc); |
69 | static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); | 70 | static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); |
70 | 71 | ||
71 | IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, rc5.ks, RC5_32, rc5, NID_rc5, | 72 | typedef struct |
72 | 8, EVP_RC5_32_12_16_KEY_SIZE, 8, | 73 | { |
73 | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | 74 | int rounds; /* number of rounds */ |
74 | r_32_12_16_init_key, NULL, | 75 | RC5_32_KEY ks; /* key schedule */ |
75 | NULL, NULL, rc5_ctrl) | 76 | } EVP_RC5_KEY; |
76 | 77 | ||
78 | #define data(ctx) EVP_C_DATA(EVP_RC5_KEY,ctx) | ||
77 | 79 | ||
80 | IMPLEMENT_BLOCK_CIPHER(rc5_32_12_16, ks, RC5_32, EVP_RC5_KEY, NID_rc5, | ||
81 | 8, RC5_32_KEY_LENGTH, 8, 64, | ||
82 | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | ||
83 | r_32_12_16_init_key, NULL, | ||
84 | NULL, NULL, rc5_ctrl) | ||
78 | 85 | ||
79 | static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) | 86 | static int rc5_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) |
80 | { | 87 | { |
81 | switch(type) { | 88 | switch(type) |
82 | 89 | { | |
83 | case EVP_CTRL_INIT: | 90 | case EVP_CTRL_INIT: |
84 | c->c.rc5.rounds = RC5_12_ROUNDS; | 91 | data(c)->rounds = RC5_12_ROUNDS; |
85 | return 1; | 92 | return 1; |
86 | 93 | ||
87 | case EVP_CTRL_GET_RC5_ROUNDS: | 94 | case EVP_CTRL_GET_RC5_ROUNDS: |
88 | *(int *)ptr = c->c.rc5.rounds; | 95 | *(int *)ptr = data(c)->rounds; |
89 | return 1; | 96 | return 1; |
90 | |||
91 | 97 | ||
92 | case EVP_CTRL_SET_RC5_ROUNDS: | 98 | case EVP_CTRL_SET_RC5_ROUNDS: |
93 | switch(arg) { | 99 | switch(arg) |
94 | case RC5_8_ROUNDS: | 100 | { |
95 | case RC5_12_ROUNDS: | 101 | case RC5_8_ROUNDS: |
96 | case RC5_16_ROUNDS: | 102 | case RC5_12_ROUNDS: |
97 | c->c.rc5.rounds = arg; | 103 | case RC5_16_ROUNDS: |
98 | return 1; | 104 | data(c)->rounds = arg; |
105 | return 1; | ||
99 | 106 | ||
100 | default: | 107 | default: |
101 | EVPerr(EVP_F_RC5_CTRL, EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS); | 108 | EVPerr(EVP_F_RC5_CTRL, EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS); |
102 | return 0; | 109 | return 0; |
103 | } | 110 | } |
104 | 111 | ||
105 | default: | 112 | default: |
106 | return -1; | 113 | return -1; |
107 | } | 114 | } |
108 | } | 115 | } |
109 | 116 | ||
110 | static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | 117 | static int r_32_12_16_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
111 | const unsigned char *iv, int enc) | 118 | const unsigned char *iv, int enc) |
112 | { | 119 | { |
113 | RC5_32_set_key(&(ctx->c.rc5.ks),EVP_CIPHER_CTX_key_length(ctx), | 120 | RC5_32_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx), |
114 | key,ctx->c.rc5.rounds); | 121 | key,data(ctx)->rounds); |
115 | return 1; | 122 | return 1; |
116 | } | 123 | } |
117 | 124 | ||
diff --git a/src/lib/libcrypto/evp/evp_test.c b/src/lib/libcrypto/evp/evp_test.c index 3607fe7776..1bfffb34cf 100644 --- a/src/lib/libcrypto/evp/evp_test.c +++ b/src/lib/libcrypto/evp/evp_test.c | |||
@@ -123,13 +123,15 @@ static unsigned char *ustrsep(char **p,const char *sep) | |||
123 | static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | 123 | static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, |
124 | const unsigned char *iv,int in, | 124 | const unsigned char *iv,int in, |
125 | const unsigned char *plaintext,int pn, | 125 | const unsigned char *plaintext,int pn, |
126 | const unsigned char *ciphertext,int cn) | 126 | const unsigned char *ciphertext,int cn, |
127 | int encdec) | ||
127 | { | 128 | { |
128 | EVP_CIPHER_CTX ctx; | 129 | EVP_CIPHER_CTX ctx; |
129 | unsigned char out[4096]; | 130 | unsigned char out[4096]; |
130 | int outl,outl2; | 131 | int outl,outl2; |
131 | 132 | ||
132 | printf("Testing cipher %s\n",EVP_CIPHER_name(c)); | 133 | printf("Testing cipher %s%s\n",EVP_CIPHER_name(c), |
134 | (encdec == 1 ? "(encrypt)" : (encdec == 0 ? "(decrypt)" : "(encrypt/decrypt)"))); | ||
133 | hexdump(stdout,"Key",key,kn); | 135 | hexdump(stdout,"Key",key,kn); |
134 | if(in) | 136 | if(in) |
135 | hexdump(stdout,"IV",iv,in); | 137 | hexdump(stdout,"IV",iv,in); |
@@ -143,79 +145,88 @@ static void test1(const EVP_CIPHER *c,const unsigned char *key,int kn, | |||
143 | exit(5); | 145 | exit(5); |
144 | } | 146 | } |
145 | EVP_CIPHER_CTX_init(&ctx); | 147 | EVP_CIPHER_CTX_init(&ctx); |
146 | if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv)) | 148 | if (encdec != 0) |
147 | { | 149 | { |
148 | fprintf(stderr,"EncryptInit failed\n"); | 150 | if(!EVP_EncryptInit_ex(&ctx,c,NULL,key,iv)) |
149 | exit(10); | 151 | { |
150 | } | 152 | fprintf(stderr,"EncryptInit failed\n"); |
151 | EVP_CIPHER_CTX_set_padding(&ctx,0); | 153 | exit(10); |
154 | } | ||
155 | EVP_CIPHER_CTX_set_padding(&ctx,0); | ||
152 | 156 | ||
153 | if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn)) | 157 | if(!EVP_EncryptUpdate(&ctx,out,&outl,plaintext,pn)) |
154 | { | 158 | { |
155 | fprintf(stderr,"Encrypt failed\n"); | 159 | fprintf(stderr,"Encrypt failed\n"); |
156 | exit(6); | 160 | exit(6); |
157 | } | 161 | } |
158 | if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2)) | 162 | if(!EVP_EncryptFinal_ex(&ctx,out+outl,&outl2)) |
159 | { | 163 | { |
160 | fprintf(stderr,"EncryptFinal failed\n"); | 164 | fprintf(stderr,"EncryptFinal failed\n"); |
161 | exit(7); | 165 | exit(7); |
162 | } | 166 | } |
163 | 167 | ||
164 | if(outl+outl2 != cn) | 168 | if(outl+outl2 != cn) |
165 | { | 169 | { |
166 | fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", | 170 | fprintf(stderr,"Ciphertext length mismatch got %d expected %d\n", |
167 | outl+outl2,cn); | 171 | outl+outl2,cn); |
168 | exit(8); | 172 | exit(8); |
169 | } | 173 | } |
170 | 174 | ||
171 | if(memcmp(out,ciphertext,cn)) | 175 | if(memcmp(out,ciphertext,cn)) |
172 | { | 176 | { |
173 | fprintf(stderr,"Ciphertext mismatch\n"); | 177 | fprintf(stderr,"Ciphertext mismatch\n"); |
174 | hexdump(stderr,"Got",out,cn); | 178 | hexdump(stderr,"Got",out,cn); |
175 | hexdump(stderr,"Expected",ciphertext,cn); | 179 | hexdump(stderr,"Expected",ciphertext,cn); |
176 | exit(9); | 180 | exit(9); |
181 | } | ||
177 | } | 182 | } |
178 | 183 | ||
179 | if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv)) | 184 | if (encdec <= 0) |
180 | { | 185 | { |
181 | fprintf(stderr,"DecryptInit failed\n"); | 186 | if(!EVP_DecryptInit_ex(&ctx,c,NULL,key,iv)) |
182 | exit(11); | 187 | { |
183 | } | 188 | fprintf(stderr,"DecryptInit failed\n"); |
184 | EVP_CIPHER_CTX_set_padding(&ctx,0); | 189 | exit(11); |
190 | } | ||
191 | EVP_CIPHER_CTX_set_padding(&ctx,0); | ||
185 | 192 | ||
186 | if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,pn)) | 193 | if(!EVP_DecryptUpdate(&ctx,out,&outl,ciphertext,cn)) |
187 | { | 194 | { |
188 | fprintf(stderr,"Decrypt failed\n"); | 195 | fprintf(stderr,"Decrypt failed\n"); |
189 | exit(6); | 196 | exit(6); |
190 | } | 197 | } |
191 | if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2)) | 198 | if(!EVP_DecryptFinal_ex(&ctx,out+outl,&outl2)) |
192 | { | 199 | { |
193 | fprintf(stderr,"DecryptFinal failed\n"); | 200 | fprintf(stderr,"DecryptFinal failed\n"); |
194 | exit(7); | 201 | exit(7); |
195 | } | 202 | } |
196 | 203 | ||
197 | if(outl+outl2 != cn) | 204 | if(outl+outl2 != cn) |
198 | { | 205 | { |
199 | fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", | 206 | fprintf(stderr,"Plaintext length mismatch got %d expected %d\n", |
200 | outl+outl2,cn); | 207 | outl+outl2,cn); |
201 | exit(8); | 208 | exit(8); |
202 | } | 209 | } |
203 | 210 | ||
204 | if(memcmp(out,plaintext,cn)) | 211 | if(memcmp(out,plaintext,cn)) |
205 | { | 212 | { |
206 | fprintf(stderr,"Plaintext mismatch\n"); | 213 | fprintf(stderr,"Plaintext mismatch\n"); |
207 | hexdump(stderr,"Got",out,cn); | 214 | hexdump(stderr,"Got",out,cn); |
208 | hexdump(stderr,"Expected",plaintext,cn); | 215 | hexdump(stderr,"Expected",plaintext,cn); |
209 | exit(9); | 216 | exit(9); |
217 | } | ||
210 | } | 218 | } |
211 | 219 | ||
220 | EVP_CIPHER_CTX_cleanup(&ctx); | ||
221 | |||
212 | printf("\n"); | 222 | printf("\n"); |
213 | } | 223 | } |
214 | 224 | ||
215 | static int test_cipher(const char *cipher,const unsigned char *key,int kn, | 225 | static int test_cipher(const char *cipher,const unsigned char *key,int kn, |
216 | const unsigned char *iv,int in, | 226 | const unsigned char *iv,int in, |
217 | const unsigned char *plaintext,int pn, | 227 | const unsigned char *plaintext,int pn, |
218 | const unsigned char *ciphertext,int cn) | 228 | const unsigned char *ciphertext,int cn, |
229 | int encdec) | ||
219 | { | 230 | { |
220 | const EVP_CIPHER *c; | 231 | const EVP_CIPHER *c; |
221 | 232 | ||
@@ -223,7 +234,7 @@ static int test_cipher(const char *cipher,const unsigned char *key,int kn, | |||
223 | if(!c) | 234 | if(!c) |
224 | return 0; | 235 | return 0; |
225 | 236 | ||
226 | test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn); | 237 | test1(c,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec); |
227 | 238 | ||
228 | return 1; | 239 | return 1; |
229 | } | 240 | } |
@@ -279,6 +290,8 @@ static int test_digest(const char *digest, | |||
279 | 290 | ||
280 | printf("\n"); | 291 | printf("\n"); |
281 | 292 | ||
293 | EVP_MD_CTX_cleanup(&ctx); | ||
294 | |||
282 | return 1; | 295 | return 1; |
283 | } | 296 | } |
284 | 297 | ||
@@ -328,6 +341,7 @@ int main(int argc,char **argv) | |||
328 | char *p; | 341 | char *p; |
329 | char *cipher; | 342 | char *cipher; |
330 | unsigned char *iv,*key,*plaintext,*ciphertext; | 343 | unsigned char *iv,*key,*plaintext,*ciphertext; |
344 | int encdec; | ||
331 | int kn,in,pn,cn; | 345 | int kn,in,pn,cn; |
332 | 346 | ||
333 | if(!fgets((char *)line,sizeof line,f)) | 347 | if(!fgets((char *)line,sizeof line,f)) |
@@ -339,14 +353,21 @@ int main(int argc,char **argv) | |||
339 | key=ustrsep(&p,":"); | 353 | key=ustrsep(&p,":"); |
340 | iv=ustrsep(&p,":"); | 354 | iv=ustrsep(&p,":"); |
341 | plaintext=ustrsep(&p,":"); | 355 | plaintext=ustrsep(&p,":"); |
342 | ciphertext=ustrsep(&p,"\n"); | 356 | ciphertext=ustrsep(&p,":"); |
357 | if (p[-1] == '\n') { | ||
358 | p[-1] = '\0'; | ||
359 | encdec = -1; | ||
360 | } else { | ||
361 | encdec = atoi(strsep(&p,"\n")); | ||
362 | } | ||
363 | |||
343 | 364 | ||
344 | kn=convert(key); | 365 | kn=convert(key); |
345 | in=convert(iv); | 366 | in=convert(iv); |
346 | pn=convert(plaintext); | 367 | pn=convert(plaintext); |
347 | cn=convert(ciphertext); | 368 | cn=convert(ciphertext); |
348 | 369 | ||
349 | if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn) | 370 | if(!test_cipher(cipher,key,kn,iv,in,plaintext,pn,ciphertext,cn,encdec) |
350 | && !test_digest(cipher,plaintext,pn,ciphertext,cn)) | 371 | && !test_digest(cipher,plaintext,pn,ciphertext,cn)) |
351 | { | 372 | { |
352 | fprintf(stderr,"Can't find %s\n",cipher); | 373 | fprintf(stderr,"Can't find %s\n",cipher); |
diff --git a/src/lib/libcrypto/evp/evptests.txt b/src/lib/libcrypto/evp/evptests.txt index 6c1529db37..80bd9c7765 100644 --- a/src/lib/libcrypto/evp/evptests.txt +++ b/src/lib/libcrypto/evp/evptests.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | #cipher:key:iv:input:output | 1 | #cipher:key:iv:plaintext:ciphertext:0/1(decrypt/encrypt) |
2 | #digest:::input:output | 2 | #digest:::input:output |
3 | 3 | ||
4 | # SHA(1) tests (from shatest.c) | 4 | # SHA(1) tests (from shatest.c) |
@@ -15,47 +15,148 @@ MD5:::31323334353637383930313233343536373839303132333435363738393031323334353637 | |||
15 | 15 | ||
16 | # AES 128 ECB tests (from FIPS-197 test vectors, encrypt) | 16 | # AES 128 ECB tests (from FIPS-197 test vectors, encrypt) |
17 | 17 | ||
18 | AES-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:69C4E0D86A7B0430D8CDB78070B4C55A | 18 | AES-128-ECB:000102030405060708090A0B0C0D0E0F::00112233445566778899AABBCCDDEEFF:69C4E0D86A7B0430D8CDB78070B4C55A:1 |
19 | 19 | ||
20 | # AES 192 ECB tests (from FIPS-197 test vectors, encrypt) | 20 | # AES 192 ECB tests (from FIPS-197 test vectors, encrypt) |
21 | 21 | ||
22 | AES-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191 | 22 | AES-192-ECB:000102030405060708090A0B0C0D0E0F1011121314151617::00112233445566778899AABBCCDDEEFF:DDA97CA4864CDFE06EAF70A0EC0D7191:1 |
23 | 23 | ||
24 | # AES 256 ECB tests (from FIPS-197 test vectors, encrypt) | 24 | # AES 256 ECB tests (from FIPS-197 test vectors, encrypt) |
25 | 25 | ||
26 | AES-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089 | 26 | AES-256-ECB:000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F::00112233445566778899AABBCCDDEEFF:8EA2B7CA516745BFEAFC49904B496089:1 |
27 | 27 | ||
28 | # AES 128 ECB tests (from NIST test vectors, encrypt) | 28 | # AES 128 ECB tests (from NIST test vectors, encrypt) |
29 | 29 | ||
30 | #AES-128-ECB:00000000000000000000000000000000::00000000000000000000000000000000:C34C052CC0DA8D73451AFE5F03BE297F | 30 | #AES-128-ECB:00000000000000000000000000000000::00000000000000000000000000000000:C34C052CC0DA8D73451AFE5F03BE297F:1 |
31 | 31 | ||
32 | # AES 128 ECB tests (from NIST test vectors, decrypt) | 32 | # AES 128 ECB tests (from NIST test vectors, decrypt) |
33 | 33 | ||
34 | #AES-128-ECB:00000000000000000000000000000000::44416AC2D1F53C583303917E6BE9EBE0:00000000000000000000000000000000 | 34 | #AES-128-ECB:00000000000000000000000000000000::44416AC2D1F53C583303917E6BE9EBE0:00000000000000000000000000000000:0 |
35 | 35 | ||
36 | # AES 192 ECB tests (from NIST test vectors, decrypt) | 36 | # AES 192 ECB tests (from NIST test vectors, decrypt) |
37 | 37 | ||
38 | #AES-192-ECB:000000000000000000000000000000000000000000000000::48E31E9E256718F29229319C19F15BA4:00000000000000000000000000000000 | 38 | #AES-192-ECB:000000000000000000000000000000000000000000000000::48E31E9E256718F29229319C19F15BA4:00000000000000000000000000000000:0 |
39 | 39 | ||
40 | # AES 256 ECB tests (from NIST test vectors, decrypt) | 40 | # AES 256 ECB tests (from NIST test vectors, decrypt) |
41 | 41 | ||
42 | #AES-256-ECB:0000000000000000000000000000000000000000000000000000000000000000::058CCFFDBBCB382D1F6F56585D8A4ADE:00000000000000000000000000000000 | 42 | #AES-256-ECB:0000000000000000000000000000000000000000000000000000000000000000::058CCFFDBBCB382D1F6F56585D8A4ADE:00000000000000000000000000000000:0 |
43 | 43 | ||
44 | # AES 128 CBC tests (from NIST test vectors, encrypt) | 44 | # AES 128 CBC tests (from NIST test vectors, encrypt) |
45 | 45 | ||
46 | #AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:8A05FC5E095AF4848A08D328D3688E3D | 46 | #AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:8A05FC5E095AF4848A08D328D3688E3D:1 |
47 | 47 | ||
48 | # AES 192 CBC tests (from NIST test vectors, encrypt) | 48 | # AES 192 CBC tests (from NIST test vectors, encrypt) |
49 | 49 | ||
50 | #AES-192-CBC:000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:7BD966D53AD8C1BB85D2ADFAE87BB104 | 50 | #AES-192-CBC:000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:7BD966D53AD8C1BB85D2ADFAE87BB104:1 |
51 | 51 | ||
52 | # AES 256 CBC tests (from NIST test vectors, encrypt) | 52 | # AES 256 CBC tests (from NIST test vectors, encrypt) |
53 | 53 | ||
54 | #AES-256-CBC:0000000000000000000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:FE3C53653E2F45B56FCD88B2CC898FF0 | 54 | #AES-256-CBC:0000000000000000000000000000000000000000000000000000000000000000:00000000000000000000000000000000:00000000000000000000000000000000:FE3C53653E2F45B56FCD88B2CC898FF0:1 |
55 | 55 | ||
56 | # AES 128 CBC tests (from NIST test vectors, decrypt) | 56 | # AES 128 CBC tests (from NIST test vectors, decrypt) |
57 | 57 | ||
58 | #AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:FACA37E0B0C85373DF706E73F7C9AF86:00000000000000000000000000000000 | 58 | #AES-128-CBC:00000000000000000000000000000000:00000000000000000000000000000000:FACA37E0B0C85373DF706E73F7C9AF86:00000000000000000000000000000000:0 |
59 | |||
60 | # AES tests from NIST document SP800-38A | ||
61 | # For all ECB encrypts and decrypts, the transformed sequence is | ||
62 | # AES-bits-ECB:key::plaintext:ciphertext:encdec | ||
63 | # ECB-AES128.Encrypt and ECB-AES128.Decrypt | ||
64 | AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::6BC1BEE22E409F96E93D7E117393172A:3AD77BB40D7A3660A89ECAF32466EF97 | ||
65 | AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::AE2D8A571E03AC9C9EB76FAC45AF8E51:F5D3D58503B9699DE785895A96FDBAAF | ||
66 | AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::30C81C46A35CE411E5FBC1191A0A52EF:43B1CD7F598ECE23881B00E3ED030688 | ||
67 | AES-128-ECB:2B7E151628AED2A6ABF7158809CF4F3C::F69F2445DF4F9B17AD2B417BE66C3710:7B0C785E27E8AD3F8223207104725DD4 | ||
68 | # ECB-AES192.Encrypt and ECB-AES192.Decrypt | ||
69 | AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::6BC1BEE22E409F96E93D7E117393172A:BD334F1D6E45F25FF712A214571FA5CC | ||
70 | AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::AE2D8A571E03AC9C9EB76FAC45AF8E51:974104846D0AD3AD7734ECB3ECEE4EEF | ||
71 | AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::30C81C46A35CE411E5FBC1191A0A52EF:EF7AFD2270E2E60ADCE0BA2FACE6444E | ||
72 | AES-192-ECB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B::F69F2445DF4F9B17AD2B417BE66C3710:9A4B41BA738D6C72FB16691603C18E0E | ||
73 | # ECB-AES256.Encrypt and ECB-AES256.Decrypt | ||
74 | AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::6BC1BEE22E409F96E93D7E117393172A:F3EED1BDB5D2A03C064B5A7E3DB181F8 | ||
75 | AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::AE2D8A571E03AC9C9EB76FAC45AF8E51:591CCB10D410ED26DC5BA74A31362870 | ||
76 | AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::30C81C46A35CE411E5FBC1191A0A52EF:B6ED21B99CA6F4F9F153E7B1BEAFED1D | ||
77 | AES-256-ECB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4::F69F2445DF4F9B17AD2B417BE66C3710:23304B7A39F9F3FF067D8D8F9E24ECC7 | ||
78 | # For all CBC encrypts and decrypts, the transformed sequence is | ||
79 | # AES-bits-CBC:key:IV/ciphertext':plaintext:ciphertext:encdec | ||
80 | # CBC-AES128.Encrypt and CBC-AES128.Decrypt | ||
81 | AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:7649ABAC8119B246CEE98E9B12E9197D | ||
82 | AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:7649ABAC8119B246CEE98E9B12E9197D:AE2D8A571E03AC9C9EB76FAC45AF8E51:5086CB9B507219EE95DB113A917678B2 | ||
83 | AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:5086CB9B507219EE95DB113A917678B2:30C81C46A35CE411E5FBC1191A0A52EF:73BED6B8E3C1743B7116E69E22229516 | ||
84 | AES-128-CBC:2B7E151628AED2A6ABF7158809CF4F3C:73BED6B8E3C1743B7116E69E22229516:F69F2445DF4F9B17AD2B417BE66C3710:3FF1CAA1681FAC09120ECA307586E1A7 | ||
85 | # CBC-AES192.Encrypt and CBC-AES192.Decrypt | ||
86 | AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:4F021DB243BC633D7178183A9FA071E8 | ||
87 | AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:4F021DB243BC633D7178183A9FA071E8:AE2D8A571E03AC9C9EB76FAC45AF8E51:B4D9ADA9AD7DEDF4E5E738763F69145A | ||
88 | AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:B4D9ADA9AD7DEDF4E5E738763F69145A:30C81C46A35CE411E5FBC1191A0A52EF:571B242012FB7AE07FA9BAAC3DF102E0 | ||
89 | AES-192-CBC:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:571B242012FB7AE07FA9BAAC3DF102E0:F69F2445DF4F9B17AD2B417BE66C3710:08B0E27988598881D920A9E64F5615CD | ||
90 | # CBC-AES256.Encrypt and CBC-AES256.Decrypt | ||
91 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:F58C4C04D6E5F1BA779EABFB5F7BFBD6 | ||
92 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:F58C4C04D6E5F1BA779EABFB5F7BFBD6:AE2D8A571E03AC9C9EB76FAC45AF8E51:9CFC4E967EDB808D679F777BC6702C7D | ||
93 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:9CFC4E967EDB808D679F777BC6702C7D:30C81C46A35CE411E5FBC1191A0A52EF:39F23369A9D9BACFA530E26304231461 | ||
94 | AES-256-CBC:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39F23369A9D9BACFA530E26304231461:F69F2445DF4F9B17AD2B417BE66C3710:B2EB05E2C39BE9FCDA6C19078C6A9D1B | ||
95 | # We don't support CFB{1,8}-AESxxx.{En,De}crypt | ||
96 | # For all CFB128 encrypts and decrypts, the transformed sequence is | ||
97 | # AES-bits-CFB:key:IV/ciphertext':plaintext:ciphertext:encdec | ||
98 | # CFB128-AES128.Encrypt | ||
99 | AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1 | ||
100 | AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:1 | ||
101 | AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:1 | ||
102 | AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:1 | ||
103 | # CFB128-AES128.Decrypt | ||
104 | AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0 | ||
105 | AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:3B3FD92EB72DAD20333449F8E83CFB4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:C8A64537A0B3A93FCDE3CDAD9F1CE58B:0 | ||
106 | AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:C8A64537A0B3A93FCDE3CDAD9F1CE58B:30C81C46A35CE411E5FBC1191A0A52EF:26751F67A3CBB140B1808CF187A4F4DF:0 | ||
107 | AES-128-CFB:2B7E151628AED2A6ABF7158809CF4F3C:26751F67A3CBB140B1808CF187A4F4DF:F69F2445DF4F9B17AD2B417BE66C3710:C04B05357C5D1C0EEAC4C66F9FF7F2E6:0 | ||
108 | # CFB128-AES192.Encrypt | ||
109 | AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1 | ||
110 | AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:1 | ||
111 | AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:1 | ||
112 | AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:1 | ||
113 | # CFB128-AES192.Decrypt | ||
114 | AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0 | ||
115 | AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:CDC80D6FDDF18CAB34C25909C99A4174:AE2D8A571E03AC9C9EB76FAC45AF8E51:67CE7F7F81173621961A2B70171D3D7A:0 | ||
116 | AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:67CE7F7F81173621961A2B70171D3D7A:30C81C46A35CE411E5FBC1191A0A52EF:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:0 | ||
117 | AES-192-CFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:2E1E8A1DD59B88B1C8E60FED1EFAC4C9:F69F2445DF4F9B17AD2B417BE66C3710:C05F9F9CA9834FA042AE8FBA584B09FF:0 | ||
118 | # CFB128-AES256.Encrypt | ||
119 | AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1 | ||
120 | AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:1 | ||
121 | AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:1 | ||
122 | AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:1 | ||
123 | # CFB128-AES256.Decrypt | ||
124 | AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0 | ||
125 | AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DC7E84BFDA79164B7ECD8486985D3860:AE2D8A571E03AC9C9EB76FAC45AF8E51:39FFED143B28B1C832113C6331E5407B:0 | ||
126 | AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:39FFED143B28B1C832113C6331E5407B:30C81C46A35CE411E5FBC1191A0A52EF:DF10132415E54B92A13ED0A8267AE2F9:0 | ||
127 | AES-256-CFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:DF10132415E54B92A13ED0A8267AE2F9:F69F2445DF4F9B17AD2B417BE66C3710:75A385741AB9CEF82031623D55B1E471:0 | ||
128 | # For all OFB encrypts and decrypts, the transformed sequence is | ||
129 | # AES-bits-CFB:key:IV/output':plaintext:ciphertext:encdec | ||
130 | # OFB-AES128.Encrypt | ||
131 | AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:1 | ||
132 | AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:1 | ||
133 | AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:1 | ||
134 | AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:1 | ||
135 | # OFB-AES128.Decrypt | ||
136 | AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:3B3FD92EB72DAD20333449F8E83CFB4A:0 | ||
137 | AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:50FE67CC996D32B6DA0937E99BAFEC60:AE2D8A571E03AC9C9EB76FAC45AF8E51:7789508D16918F03F53C52DAC54ED825:0 | ||
138 | AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:D9A4DADA0892239F6B8B3D7680E15674:30C81C46A35CE411E5FBC1191A0A52EF:9740051E9C5FECF64344F7A82260EDCC:0 | ||
139 | AES-128-OFB:2B7E151628AED2A6ABF7158809CF4F3C:A78819583F0308E7A6BF36B1386ABF23:F69F2445DF4F9B17AD2B417BE66C3710:304C6528F659C77866A510D9C1D6AE5E:0 | ||
140 | # OFB-AES192.Encrypt | ||
141 | AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:1 | ||
142 | AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:1 | ||
143 | AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:1 | ||
144 | AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:1 | ||
145 | # OFB-AES192.Decrypt | ||
146 | AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:CDC80D6FDDF18CAB34C25909C99A4174:0 | ||
147 | AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:A609B38DF3B1133DDDFF2718BA09565E:AE2D8A571E03AC9C9EB76FAC45AF8E51:FCC28B8D4C63837C09E81700C1100401:0 | ||
148 | AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:52EF01DA52602FE0975F78AC84BF8A50:30C81C46A35CE411E5FBC1191A0A52EF:8D9A9AEAC0F6596F559C6D4DAF59A5F2:0 | ||
149 | AES-192-OFB:8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B:BD5286AC63AABD7EB067AC54B553F71D:F69F2445DF4F9B17AD2B417BE66C3710:6D9F200857CA6C3E9CAC524BD9ACC92A:0 | ||
150 | # OFB-AES256.Encrypt | ||
151 | AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:1 | ||
152 | AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:1 | ||
153 | AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:1 | ||
154 | AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:1 | ||
155 | # OFB-AES256.Decrypt | ||
156 | AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:000102030405060708090A0B0C0D0E0F:6BC1BEE22E409F96E93D7E117393172A:DC7E84BFDA79164B7ECD8486985D3860:0 | ||
157 | AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:B7BF3A5DF43989DD97F0FA97EBCE2F4A:AE2D8A571E03AC9C9EB76FAC45AF8E51:4FEBDC6740D20B3AC88F6AD82A4FB08D:0 | ||
158 | AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:E1C656305ED1A7A6563805746FE03EDC:30C81C46A35CE411E5FBC1191A0A52EF:71AB47A086E86EEDF39D1C5BBA97C408:0 | ||
159 | AES-256-OFB:603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4:41635BE625B48AFC1666DD42A09D96E7:F69F2445DF4F9B17AD2B417BE66C3710:0126141D67F37BE8538F5A8BE740E484:0 | ||
59 | 160 | ||
60 | # DES ECB tests (from destest) | 161 | # DES ECB tests (from destest) |
61 | 162 | ||
diff --git a/src/lib/libcrypto/evp/m_md2.c b/src/lib/libcrypto/evp/m_md2.c index 2209416142..50914c83b3 100644 --- a/src/lib/libcrypto/evp/m_md2.c +++ b/src/lib/libcrypto/evp/m_md2.c | |||
@@ -56,27 +56,41 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef OPENSSL_NO_MD2 | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | #include "evp.h" | 62 | #include <openssl/evp.h> |
62 | #include "objects.h" | 63 | #include <openssl/objects.h> |
63 | #include "x509.h" | 64 | #include <openssl/x509.h> |
65 | #include <openssl/md2.h> | ||
64 | 66 | ||
65 | static EVP_MD md2_md= | 67 | static int init(EVP_MD_CTX *ctx) |
68 | { return MD2_Init(ctx->md_data); } | ||
69 | |||
70 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
71 | { return MD2_Update(ctx->md_data,data,count); } | ||
72 | |||
73 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
74 | { return MD2_Final(md,ctx->md_data); } | ||
75 | |||
76 | static const EVP_MD md2_md= | ||
66 | { | 77 | { |
67 | NID_md2, | 78 | NID_md2, |
68 | NID_md2WithRSAEncryption, | 79 | NID_md2WithRSAEncryption, |
69 | MD2_DIGEST_LENGTH, | 80 | MD2_DIGEST_LENGTH, |
70 | MD2_Init, | 81 | 0, |
71 | MD2_Update, | 82 | init, |
72 | MD2_Final, | 83 | update, |
84 | final, | ||
85 | NULL, | ||
86 | NULL, | ||
73 | EVP_PKEY_RSA_method, | 87 | EVP_PKEY_RSA_method, |
74 | MD2_BLOCK, | 88 | MD2_BLOCK, |
75 | sizeof(EVP_MD *)+sizeof(MD2_CTX), | 89 | sizeof(EVP_MD *)+sizeof(MD2_CTX), |
76 | }; | 90 | }; |
77 | 91 | ||
78 | EVP_MD *EVP_md2() | 92 | const EVP_MD *EVP_md2(void) |
79 | { | 93 | { |
80 | return(&md2_md); | 94 | return(&md2_md); |
81 | } | 95 | } |
82 | 96 | #endif | |
diff --git a/src/lib/libcrypto/evp/m_mdc2.c b/src/lib/libcrypto/evp/m_mdc2.c index 64a853eb7f..9f6467c931 100644 --- a/src/lib/libcrypto/evp/m_mdc2.c +++ b/src/lib/libcrypto/evp/m_mdc2.c | |||
@@ -56,26 +56,41 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef OPENSSL_NO_MDC2 | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | #include "evp.h" | 62 | #include <openssl/evp.h> |
62 | #include "objects.h" | 63 | #include <openssl/objects.h> |
63 | #include "x509.h" | 64 | #include <openssl/x509.h> |
65 | #include <openssl/mdc2.h> | ||
64 | 66 | ||
65 | static EVP_MD mdc2_md= | 67 | static int init(EVP_MD_CTX *ctx) |
68 | { return MDC2_Init(ctx->md_data); } | ||
69 | |||
70 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
71 | { return MDC2_Update(ctx->md_data,data,count); } | ||
72 | |||
73 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
74 | { return MDC2_Final(md,ctx->md_data); } | ||
75 | |||
76 | static const EVP_MD mdc2_md= | ||
66 | { | 77 | { |
67 | NID_mdc2, | 78 | NID_mdc2, |
68 | NID_mdc2WithRSA, | 79 | NID_mdc2WithRSA, |
69 | MDC2_DIGEST_LENGTH, | 80 | MDC2_DIGEST_LENGTH, |
70 | MDC2_Init, | 81 | 0, |
71 | MDC2_Update, | 82 | init, |
72 | MDC2_Final, | 83 | update, |
84 | final, | ||
85 | NULL, | ||
86 | NULL, | ||
73 | EVP_PKEY_RSA_ASN1_OCTET_STRING_method, | 87 | EVP_PKEY_RSA_ASN1_OCTET_STRING_method, |
74 | MDC2_BLOCK, | 88 | MDC2_BLOCK, |
75 | sizeof(EVP_MD *)+sizeof(MDC2_CTX), | 89 | sizeof(EVP_MD *)+sizeof(MDC2_CTX), |
76 | }; | 90 | }; |
77 | 91 | ||
78 | EVP_MD *EVP_mdc2() | 92 | const EVP_MD *EVP_mdc2(void) |
79 | { | 93 | { |
80 | return(&mdc2_md); | 94 | return(&mdc2_md); |
81 | } | 95 | } |
96 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_sha.c b/src/lib/libcrypto/evp/m_sha.c index af4e434a22..10697c7ed3 100644 --- a/src/lib/libcrypto/evp/m_sha.c +++ b/src/lib/libcrypto/evp/m_sha.c | |||
@@ -56,27 +56,40 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #ifndef OPENSSL_NO_SHA | ||
59 | #include <stdio.h> | 60 | #include <stdio.h> |
60 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
61 | #include "evp.h" | 62 | #include <openssl/evp.h> |
62 | #include "objects.h" | 63 | #include <openssl/objects.h> |
63 | #include "x509.h" | 64 | #include <openssl/x509.h> |
64 | 65 | ||
65 | static EVP_MD sha_md= | 66 | static int init(EVP_MD_CTX *ctx) |
67 | { return SHA_Init(ctx->md_data); } | ||
68 | |||
69 | static int update(EVP_MD_CTX *ctx,const void *data,unsigned long count) | ||
70 | { return SHA_Update(ctx->md_data,data,count); } | ||
71 | |||
72 | static int final(EVP_MD_CTX *ctx,unsigned char *md) | ||
73 | { return SHA_Final(md,ctx->md_data); } | ||
74 | |||
75 | static const EVP_MD sha_md= | ||
66 | { | 76 | { |
67 | NID_sha, | 77 | NID_sha, |
68 | NID_shaWithRSAEncryption, | 78 | NID_shaWithRSAEncryption, |
69 | SHA_DIGEST_LENGTH, | 79 | SHA_DIGEST_LENGTH, |
70 | SHA_Init, | 80 | 0, |
71 | SHA_Update, | 81 | init, |
72 | SHA_Final, | 82 | update, |
83 | final, | ||
84 | NULL, | ||
85 | NULL, | ||
73 | EVP_PKEY_RSA_method, | 86 | EVP_PKEY_RSA_method, |
74 | SHA_CBLOCK, | 87 | SHA_CBLOCK, |
75 | sizeof(EVP_MD *)+sizeof(SHA_CTX), | 88 | sizeof(EVP_MD *)+sizeof(SHA_CTX), |
76 | }; | 89 | }; |
77 | 90 | ||
78 | EVP_MD *EVP_sha() | 91 | const EVP_MD *EVP_sha(void) |
79 | { | 92 | { |
80 | return(&sha_md); | 93 | return(&sha_md); |
81 | } | 94 | } |
82 | 95 | #endif | |