diff options
| author | cvs2svn <admin@example.com> | 2000-04-30 04:58:23 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2000-04-30 04:58:23 +0000 |
| commit | 9cc1eacd8366faaa248a9aca9120fb7427c2a58e (patch) | |
| tree | 9304b7a65ac1d9eeb42cdd518d69fd21eb2b47af /src/lib/libcrypto/evp | |
| parent | e71289f71fad3f153975fd8fbf1f0f35dbda7f28 (diff) | |
| download | openbsd-OPENBSD_2_7_BASE.tar.gz openbsd-OPENBSD_2_7_BASE.tar.bz2 openbsd-OPENBSD_2_7_BASE.zip | |
This commit was manufactured by cvs2git to create tag 'OPENBSD_2_7_BASE'.OPENBSD_2_7_BASE
Diffstat (limited to 'src/lib/libcrypto/evp')
32 files changed, 0 insertions, 6099 deletions
diff --git a/src/lib/libcrypto/evp/bio_b64.c b/src/lib/libcrypto/evp/bio_b64.c deleted file mode 100644 index bd5e24f993..0000000000 --- a/src/lib/libcrypto/evp/bio_b64.c +++ /dev/null | |||
| @@ -1,540 +0,0 @@ | |||
| 1 | /* crypto/evp/bio_b64.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <errno.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/buffer.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | |||
| 65 | static int b64_write(BIO *h,char *buf,int num); | ||
| 66 | static int b64_read(BIO *h,char *buf,int size); | ||
| 67 | /*static int b64_puts(BIO *h,char *str); */ | ||
| 68 | /*static int b64_gets(BIO *h,char *str,int size); */ | ||
| 69 | static long b64_ctrl(BIO *h,int cmd,long arg1,char *arg2); | ||
| 70 | static int b64_new(BIO *h); | ||
| 71 | static int b64_free(BIO *data); | ||
| 72 | static long b64_callback_ctrl(BIO *h,int cmd,void (*fp)()); | ||
| 73 | #define B64_BLOCK_SIZE 1024 | ||
| 74 | #define B64_BLOCK_SIZE2 768 | ||
| 75 | #define B64_NONE 0 | ||
| 76 | #define B64_ENCODE 1 | ||
| 77 | #define B64_DECODE 2 | ||
| 78 | |||
| 79 | typedef struct b64_struct | ||
| 80 | { | ||
| 81 | /*BIO *bio; moved to the BIO structure */ | ||
| 82 | int buf_len; | ||
| 83 | int buf_off; | ||
| 84 | int tmp_len; /* used to find the start when decoding */ | ||
| 85 | int tmp_nl; /* If true, scan until '\n' */ | ||
| 86 | int encode; | ||
| 87 | int start; /* have we started decoding yet? */ | ||
| 88 | int cont; /* <= 0 when finished */ | ||
| 89 | EVP_ENCODE_CTX base64; | ||
| 90 | char buf[EVP_ENCODE_LENGTH(B64_BLOCK_SIZE)+10]; | ||
| 91 | char tmp[B64_BLOCK_SIZE]; | ||
| 92 | } BIO_B64_CTX; | ||
| 93 | |||
| 94 | static BIO_METHOD methods_b64= | ||
| 95 | { | ||
| 96 | BIO_TYPE_BASE64,"base64 encoding", | ||
| 97 | b64_write, | ||
| 98 | b64_read, | ||
| 99 | NULL, /* b64_puts, */ | ||
| 100 | NULL, /* b64_gets, */ | ||
| 101 | b64_ctrl, | ||
| 102 | b64_new, | ||
| 103 | b64_free, | ||
| 104 | b64_callback_ctrl, | ||
| 105 | }; | ||
| 106 | |||
| 107 | BIO_METHOD *BIO_f_base64(void) | ||
| 108 | { | ||
| 109 | return(&methods_b64); | ||
| 110 | } | ||
| 111 | |||
| 112 | static int b64_new(BIO *bi) | ||
| 113 | { | ||
| 114 | BIO_B64_CTX *ctx; | ||
| 115 | |||
| 116 | ctx=(BIO_B64_CTX *)Malloc(sizeof(BIO_B64_CTX)); | ||
| 117 | if (ctx == NULL) return(0); | ||
| 118 | |||
| 119 | ctx->buf_len=0; | ||
| 120 | ctx->tmp_len=0; | ||
| 121 | ctx->tmp_nl=0; | ||
| 122 | ctx->buf_off=0; | ||
| 123 | ctx->cont=1; | ||
| 124 | ctx->start=1; | ||
| 125 | ctx->encode=0; | ||
| 126 | |||
| 127 | bi->init=1; | ||
| 128 | bi->ptr=(char *)ctx; | ||
| 129 | bi->flags=0; | ||
| 130 | return(1); | ||
| 131 | } | ||
| 132 | |||
| 133 | static int b64_free(BIO *a) | ||
| 134 | { | ||
| 135 | if (a == NULL) return(0); | ||
| 136 | Free(a->ptr); | ||
| 137 | a->ptr=NULL; | ||
| 138 | a->init=0; | ||
| 139 | a->flags=0; | ||
| 140 | return(1); | ||
| 141 | } | ||
| 142 | |||
| 143 | static int b64_read(BIO *b, char *out, int outl) | ||
| 144 | { | ||
| 145 | int ret=0,i,ii,j,k,x,n,num,ret_code=0; | ||
| 146 | BIO_B64_CTX *ctx; | ||
| 147 | unsigned char *p,*q; | ||
| 148 | |||
| 149 | if (out == NULL) return(0); | ||
| 150 | ctx=(BIO_B64_CTX *)b->ptr; | ||
| 151 | |||
| 152 | if ((ctx == NULL) || (b->next_bio == NULL)) return(0); | ||
| 153 | |||
| 154 | if (ctx->encode != B64_DECODE) | ||
| 155 | { | ||
| 156 | ctx->encode=B64_DECODE; | ||
| 157 | ctx->buf_len=0; | ||
| 158 | ctx->buf_off=0; | ||
| 159 | ctx->tmp_len=0; | ||
| 160 | EVP_DecodeInit(&(ctx->base64)); | ||
| 161 | } | ||
| 162 | |||
| 163 | /* First check if there are bytes decoded/encoded */ | ||
| 164 | if (ctx->buf_len > 0) | ||
| 165 | { | ||
| 166 | i=ctx->buf_len-ctx->buf_off; | ||
| 167 | if (i > outl) i=outl; | ||
| 168 | memcpy(out,&(ctx->buf[ctx->buf_off]),i); | ||
| 169 | ret=i; | ||
| 170 | out+=i; | ||
| 171 | outl-=i; | ||
| 172 | ctx->buf_off+=i; | ||
| 173 | if (ctx->buf_len == ctx->buf_off) | ||
| 174 | { | ||
| 175 | ctx->buf_len=0; | ||
| 176 | ctx->buf_off=0; | ||
| 177 | } | ||
| 178 | } | ||
| 179 | |||
| 180 | /* At this point, we have room of outl bytes and an empty | ||
| 181 | * buffer, so we should read in some more. */ | ||
| 182 | |||
| 183 | ret_code=0; | ||
| 184 | while (outl > 0) | ||
| 185 | { | ||
| 186 | if (ctx->cont <= 0) break; | ||
| 187 | |||
| 188 | i=BIO_read(b->next_bio,&(ctx->tmp[ctx->tmp_len]), | ||
| 189 | B64_BLOCK_SIZE-ctx->tmp_len); | ||
| 190 | |||
| 191 | if (i <= 0) | ||
| 192 | { | ||
| 193 | ret_code=i; | ||
| 194 | |||
| 195 | /* Should be continue next time we are called? */ | ||
| 196 | if (!BIO_should_retry(b->next_bio)) | ||
| 197 | ctx->cont=i; | ||
| 198 | /* else we should continue when called again */ | ||
| 199 | break; | ||
| 200 | } | ||
| 201 | i+=ctx->tmp_len; | ||
| 202 | |||
| 203 | /* We need to scan, a line at a time until we | ||
| 204 | * have a valid line if we are starting. */ | ||
| 205 | if (ctx->start && (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL)) | ||
| 206 | { | ||
| 207 | /* ctx->start=1; */ | ||
| 208 | ctx->tmp_len=0; | ||
| 209 | } | ||
| 210 | else if (ctx->start) | ||
| 211 | { | ||
| 212 | q=p=(unsigned char *)ctx->tmp; | ||
| 213 | for (j=0; j<i; j++) | ||
| 214 | { | ||
| 215 | if (*(q++) != '\n') continue; | ||
| 216 | |||
| 217 | /* due to a previous very long line, | ||
| 218 | * we need to keep on scanning for a '\n' | ||
| 219 | * before we even start looking for | ||
| 220 | * base64 encoded stuff. */ | ||
| 221 | if (ctx->tmp_nl) | ||
| 222 | { | ||
| 223 | p=q; | ||
| 224 | ctx->tmp_nl=0; | ||
| 225 | continue; | ||
| 226 | } | ||
| 227 | |||
| 228 | k=EVP_DecodeUpdate(&(ctx->base64), | ||
| 229 | (unsigned char *)ctx->buf, | ||
| 230 | &num,p,q-p); | ||
| 231 | if ((k <= 0) && (num == 0) && (ctx->start)) | ||
| 232 | EVP_DecodeInit(&ctx->base64); | ||
| 233 | else | ||
| 234 | { | ||
| 235 | if (p != (unsigned char *) | ||
| 236 | &(ctx->tmp[0])) | ||
| 237 | { | ||
| 238 | i-=(p- (unsigned char *) | ||
| 239 | &(ctx->tmp[0])); | ||
| 240 | for (x=0; x < i; x++) | ||
| 241 | ctx->tmp[x]=p[x]; | ||
| 242 | } | ||
| 243 | EVP_DecodeInit(&ctx->base64); | ||
| 244 | ctx->start=0; | ||
| 245 | break; | ||
| 246 | } | ||
| 247 | p=q; | ||
| 248 | } | ||
| 249 | |||
| 250 | /* we fell off the end without starting */ | ||
| 251 | if (j == i) | ||
| 252 | { | ||
| 253 | /* Is this is one long chunk?, if so, keep on | ||
| 254 | * reading until a new line. */ | ||
| 255 | if (p == (unsigned char *)&(ctx->tmp[0])) | ||
| 256 | { | ||
| 257 | ctx->tmp_nl=1; | ||
| 258 | ctx->tmp_len=0; | ||
| 259 | } | ||
| 260 | else if (p != q) /* finished on a '\n' */ | ||
| 261 | { | ||
| 262 | n=q-p; | ||
| 263 | for (ii=0; ii<n; ii++) | ||
| 264 | ctx->tmp[ii]=p[ii]; | ||
| 265 | ctx->tmp_len=n; | ||
| 266 | } | ||
| 267 | /* else finished on a '\n' */ | ||
| 268 | continue; | ||
| 269 | } | ||
| 270 | else | ||
| 271 | ctx->tmp_len=0; | ||
| 272 | } | ||
| 273 | |||
| 274 | if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) | ||
| 275 | { | ||
| 276 | int z,jj; | ||
| 277 | |||
| 278 | jj=(i>>2)<<2; | ||
| 279 | z=EVP_DecodeBlock((unsigned char *)ctx->buf, | ||
| 280 | (unsigned char *)ctx->tmp,jj); | ||
| 281 | if (jj > 2) | ||
| 282 | { | ||
| 283 | if (ctx->tmp[jj-1] == '=') | ||
| 284 | { | ||
| 285 | z--; | ||
| 286 | if (ctx->tmp[jj-2] == '=') | ||
| 287 | z--; | ||
| 288 | } | ||
| 289 | } | ||
| 290 | /* z is now number of output bytes and jj is the | ||
| 291 | * number consumed */ | ||
| 292 | if (jj != i) | ||
| 293 | { | ||
| 294 | memcpy((unsigned char *)ctx->tmp, | ||
| 295 | (unsigned char *)&(ctx->tmp[jj]),i-jj); | ||
| 296 | ctx->tmp_len=i-jj; | ||
| 297 | } | ||
| 298 | ctx->buf_len=0; | ||
| 299 | if (z > 0) | ||
| 300 | { | ||
| 301 | ctx->buf_len=z; | ||
| 302 | i=1; | ||
| 303 | } | ||
| 304 | else | ||
| 305 | i=z; | ||
| 306 | } | ||
| 307 | else | ||
| 308 | { | ||
| 309 | i=EVP_DecodeUpdate(&(ctx->base64), | ||
| 310 | (unsigned char *)ctx->buf,&ctx->buf_len, | ||
| 311 | (unsigned char *)ctx->tmp,i); | ||
| 312 | } | ||
| 313 | ctx->cont=i; | ||
| 314 | ctx->buf_off=0; | ||
| 315 | if (i < 0) | ||
| 316 | { | ||
| 317 | ret_code=0; | ||
| 318 | ctx->buf_len=0; | ||
| 319 | break; | ||
| 320 | } | ||
| 321 | |||
| 322 | if (ctx->buf_len <= outl) | ||
| 323 | i=ctx->buf_len; | ||
| 324 | else | ||
| 325 | i=outl; | ||
| 326 | |||
| 327 | memcpy(out,ctx->buf,i); | ||
| 328 | ret+=i; | ||
| 329 | ctx->buf_off=i; | ||
| 330 | if (ctx->buf_off == ctx->buf_len) | ||
| 331 | { | ||
| 332 | ctx->buf_len=0; | ||
| 333 | ctx->buf_off=0; | ||
| 334 | } | ||
| 335 | outl-=i; | ||
| 336 | out+=i; | ||
| 337 | } | ||
| 338 | BIO_clear_retry_flags(b); | ||
| 339 | BIO_copy_next_retry(b); | ||
| 340 | return((ret == 0)?ret_code:ret); | ||
| 341 | } | ||
| 342 | |||
| 343 | static int b64_write(BIO *b, char *in, int inl) | ||
| 344 | { | ||
| 345 | int ret=inl,n,i; | ||
| 346 | BIO_B64_CTX *ctx; | ||
| 347 | |||
| 348 | ctx=(BIO_B64_CTX *)b->ptr; | ||
| 349 | BIO_clear_retry_flags(b); | ||
| 350 | |||
| 351 | if (ctx->encode != B64_ENCODE) | ||
| 352 | { | ||
| 353 | ctx->encode=B64_ENCODE; | ||
| 354 | ctx->buf_len=0; | ||
| 355 | ctx->buf_off=0; | ||
| 356 | ctx->tmp_len=0; | ||
| 357 | EVP_EncodeInit(&(ctx->base64)); | ||
| 358 | } | ||
| 359 | |||
| 360 | n=ctx->buf_len-ctx->buf_off; | ||
| 361 | while (n > 0) | ||
| 362 | { | ||
| 363 | i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); | ||
| 364 | if (i <= 0) | ||
| 365 | { | ||
| 366 | BIO_copy_next_retry(b); | ||
| 367 | return(i); | ||
| 368 | } | ||
| 369 | ctx->buf_off+=i; | ||
| 370 | n-=i; | ||
| 371 | } | ||
| 372 | /* at this point all pending data has been written */ | ||
| 373 | |||
| 374 | if ((in == NULL) || (inl <= 0)) return(0); | ||
| 375 | |||
| 376 | ctx->buf_off=0; | ||
| 377 | while (inl > 0) | ||
| 378 | { | ||
| 379 | n=(inl > B64_BLOCK_SIZE)?B64_BLOCK_SIZE:inl; | ||
| 380 | |||
| 381 | if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) | ||
| 382 | { | ||
| 383 | if (ctx->tmp_len > 0) | ||
| 384 | { | ||
| 385 | n=3-ctx->tmp_len; | ||
| 386 | memcpy(&(ctx->tmp[ctx->tmp_len]),in,n); | ||
| 387 | ctx->tmp_len+=n; | ||
| 388 | n=ctx->tmp_len; | ||
| 389 | if (n < 3) | ||
| 390 | break; | ||
| 391 | ctx->buf_len=EVP_EncodeBlock( | ||
| 392 | (unsigned char *)ctx->buf, | ||
| 393 | (unsigned char *)ctx->tmp,n); | ||
| 394 | } | ||
| 395 | else | ||
| 396 | { | ||
| 397 | if (n < 3) | ||
| 398 | { | ||
| 399 | memcpy(&(ctx->tmp[0]),in,n); | ||
| 400 | ctx->tmp_len=n; | ||
| 401 | break; | ||
| 402 | } | ||
| 403 | n-=n%3; | ||
| 404 | ctx->buf_len=EVP_EncodeBlock( | ||
| 405 | (unsigned char *)ctx->buf, | ||
| 406 | (unsigned char *)in,n); | ||
| 407 | } | ||
| 408 | } | ||
| 409 | else | ||
| 410 | { | ||
| 411 | EVP_EncodeUpdate(&(ctx->base64), | ||
| 412 | (unsigned char *)ctx->buf,&ctx->buf_len, | ||
| 413 | (unsigned char *)in,n); | ||
| 414 | } | ||
| 415 | inl-=n; | ||
| 416 | in+=n; | ||
| 417 | |||
| 418 | ctx->buf_off=0; | ||
| 419 | n=ctx->buf_len; | ||
| 420 | while (n > 0) | ||
| 421 | { | ||
| 422 | i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); | ||
| 423 | if (i <= 0) | ||
| 424 | { | ||
| 425 | BIO_copy_next_retry(b); | ||
| 426 | return((ret == 0)?i:ret); | ||
| 427 | } | ||
| 428 | n-=i; | ||
| 429 | ctx->buf_off+=i; | ||
| 430 | } | ||
| 431 | ctx->buf_len=0; | ||
| 432 | ctx->buf_off=0; | ||
| 433 | } | ||
| 434 | return(ret); | ||
| 435 | } | ||
| 436 | |||
| 437 | static long b64_ctrl(BIO *b, int cmd, long num, char *ptr) | ||
| 438 | { | ||
| 439 | BIO_B64_CTX *ctx; | ||
| 440 | long ret=1; | ||
| 441 | int i; | ||
| 442 | |||
| 443 | ctx=(BIO_B64_CTX *)b->ptr; | ||
| 444 | |||
| 445 | switch (cmd) | ||
| 446 | { | ||
| 447 | case BIO_CTRL_RESET: | ||
| 448 | ctx->cont=1; | ||
| 449 | ctx->start=1; | ||
| 450 | ctx->encode=B64_NONE; | ||
| 451 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 452 | break; | ||
| 453 | case BIO_CTRL_EOF: /* More to read */ | ||
| 454 | if (ctx->cont <= 0) | ||
| 455 | ret=1; | ||
| 456 | else | ||
| 457 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 458 | break; | ||
| 459 | case BIO_CTRL_WPENDING: /* More to write in buffer */ | ||
| 460 | ret=ctx->buf_len-ctx->buf_off; | ||
| 461 | if ((ret == 0) && (ctx->base64.num != 0)) | ||
| 462 | ret=1; | ||
| 463 | else if (ret <= 0) | ||
| 464 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 465 | break; | ||
| 466 | case BIO_CTRL_PENDING: /* More to read in buffer */ | ||
| 467 | ret=ctx->buf_len-ctx->buf_off; | ||
| 468 | if (ret <= 0) | ||
| 469 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 470 | break; | ||
| 471 | case BIO_CTRL_FLUSH: | ||
| 472 | /* do a final write */ | ||
| 473 | again: | ||
| 474 | while (ctx->buf_len != ctx->buf_off) | ||
| 475 | { | ||
| 476 | i=b64_write(b,NULL,0); | ||
| 477 | if (i < 0) | ||
| 478 | { | ||
| 479 | ret=i; | ||
| 480 | break; | ||
| 481 | } | ||
| 482 | } | ||
| 483 | if (BIO_get_flags(b) & BIO_FLAGS_BASE64_NO_NL) | ||
| 484 | { | ||
| 485 | if (ctx->tmp_len != 0) | ||
| 486 | { | ||
| 487 | ctx->buf_len=EVP_EncodeBlock( | ||
| 488 | (unsigned char *)ctx->buf, | ||
| 489 | (unsigned char *)ctx->tmp, | ||
| 490 | ctx->tmp_len); | ||
| 491 | ctx->buf_off=0; | ||
| 492 | ctx->tmp_len=0; | ||
| 493 | goto again; | ||
| 494 | } | ||
| 495 | } | ||
| 496 | else if (ctx->base64.num != 0) | ||
| 497 | { | ||
| 498 | ctx->buf_off=0; | ||
| 499 | EVP_EncodeFinal(&(ctx->base64), | ||
| 500 | (unsigned char *)ctx->buf, | ||
| 501 | &(ctx->buf_len)); | ||
| 502 | /* push out the bytes */ | ||
| 503 | goto again; | ||
| 504 | } | ||
| 505 | /* Finally flush the underlying BIO */ | ||
| 506 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 507 | break; | ||
| 508 | |||
| 509 | case BIO_C_DO_STATE_MACHINE: | ||
| 510 | BIO_clear_retry_flags(b); | ||
| 511 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 512 | BIO_copy_next_retry(b); | ||
| 513 | break; | ||
| 514 | |||
| 515 | case BIO_CTRL_DUP: | ||
| 516 | break; | ||
| 517 | case BIO_CTRL_INFO: | ||
| 518 | case BIO_CTRL_GET: | ||
| 519 | case BIO_CTRL_SET: | ||
| 520 | default: | ||
| 521 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 522 | break; | ||
| 523 | } | ||
| 524 | return(ret); | ||
| 525 | } | ||
| 526 | |||
| 527 | static long b64_callback_ctrl(BIO *b, int cmd, void (*fp)()) | ||
| 528 | { | ||
| 529 | long ret=1; | ||
| 530 | |||
| 531 | if (b->next_bio == NULL) return(0); | ||
| 532 | switch (cmd) | ||
| 533 | { | ||
| 534 | default: | ||
| 535 | ret=BIO_callback_ctrl(b->next_bio,cmd,fp); | ||
| 536 | break; | ||
| 537 | } | ||
| 538 | return(ret); | ||
| 539 | } | ||
| 540 | |||
diff --git a/src/lib/libcrypto/evp/bio_enc.c b/src/lib/libcrypto/evp/bio_enc.c deleted file mode 100644 index 629bf4b95d..0000000000 --- a/src/lib/libcrypto/evp/bio_enc.c +++ /dev/null | |||
| @@ -1,425 +0,0 @@ | |||
| 1 | /* crypto/evp/bio_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <errno.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/buffer.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | |||
| 65 | static int enc_write(BIO *h,char *buf,int num); | ||
| 66 | static int enc_read(BIO *h,char *buf,int size); | ||
| 67 | /*static int enc_puts(BIO *h,char *str); */ | ||
| 68 | /*static int enc_gets(BIO *h,char *str,int size); */ | ||
| 69 | static long enc_ctrl(BIO *h,int cmd,long arg1,char *arg2); | ||
| 70 | static int enc_new(BIO *h); | ||
| 71 | static int enc_free(BIO *data); | ||
| 72 | static long enc_callback_ctrl(BIO *h,int cmd,void (*fp)()); | ||
| 73 | #define ENC_BLOCK_SIZE (1024*4) | ||
| 74 | |||
| 75 | typedef struct enc_struct | ||
| 76 | { | ||
| 77 | int buf_len; | ||
| 78 | int buf_off; | ||
| 79 | int cont; /* <= 0 when finished */ | ||
| 80 | int finished; | ||
| 81 | int ok; /* bad decrypt */ | ||
| 82 | EVP_CIPHER_CTX cipher; | ||
| 83 | char buf[ENC_BLOCK_SIZE+10]; | ||
| 84 | } BIO_ENC_CTX; | ||
| 85 | |||
| 86 | static BIO_METHOD methods_enc= | ||
| 87 | { | ||
| 88 | BIO_TYPE_CIPHER,"cipher", | ||
| 89 | enc_write, | ||
| 90 | enc_read, | ||
| 91 | NULL, /* enc_puts, */ | ||
| 92 | NULL, /* enc_gets, */ | ||
| 93 | enc_ctrl, | ||
| 94 | enc_new, | ||
| 95 | enc_free, | ||
| 96 | enc_callback_ctrl, | ||
| 97 | }; | ||
| 98 | |||
| 99 | BIO_METHOD *BIO_f_cipher(void) | ||
| 100 | { | ||
| 101 | return(&methods_enc); | ||
| 102 | } | ||
| 103 | |||
| 104 | static int enc_new(BIO *bi) | ||
| 105 | { | ||
| 106 | BIO_ENC_CTX *ctx; | ||
| 107 | |||
| 108 | ctx=(BIO_ENC_CTX *)Malloc(sizeof(BIO_ENC_CTX)); | ||
| 109 | EVP_CIPHER_CTX_init(&ctx->cipher); | ||
| 110 | if (ctx == NULL) return(0); | ||
| 111 | |||
| 112 | ctx->buf_len=0; | ||
| 113 | ctx->buf_off=0; | ||
| 114 | ctx->cont=1; | ||
| 115 | ctx->finished=0; | ||
| 116 | ctx->ok=1; | ||
| 117 | |||
| 118 | bi->init=0; | ||
| 119 | bi->ptr=(char *)ctx; | ||
| 120 | bi->flags=0; | ||
| 121 | return(1); | ||
| 122 | } | ||
| 123 | |||
| 124 | static int enc_free(BIO *a) | ||
| 125 | { | ||
| 126 | BIO_ENC_CTX *b; | ||
| 127 | |||
| 128 | if (a == NULL) return(0); | ||
| 129 | b=(BIO_ENC_CTX *)a->ptr; | ||
| 130 | EVP_CIPHER_CTX_cleanup(&(b->cipher)); | ||
| 131 | memset(a->ptr,0,sizeof(BIO_ENC_CTX)); | ||
| 132 | Free(a->ptr); | ||
| 133 | a->ptr=NULL; | ||
| 134 | a->init=0; | ||
| 135 | a->flags=0; | ||
| 136 | return(1); | ||
| 137 | } | ||
| 138 | |||
| 139 | static int enc_read(BIO *b, char *out, int outl) | ||
| 140 | { | ||
| 141 | int ret=0,i; | ||
| 142 | BIO_ENC_CTX *ctx; | ||
| 143 | |||
| 144 | if (out == NULL) return(0); | ||
| 145 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
| 146 | |||
| 147 | if ((ctx == NULL) || (b->next_bio == NULL)) return(0); | ||
| 148 | |||
| 149 | /* First check if there are bytes decoded/encoded */ | ||
| 150 | if (ctx->buf_len > 0) | ||
| 151 | { | ||
| 152 | i=ctx->buf_len-ctx->buf_off; | ||
| 153 | if (i > outl) i=outl; | ||
| 154 | memcpy(out,&(ctx->buf[ctx->buf_off]),i); | ||
| 155 | ret=i; | ||
| 156 | out+=i; | ||
| 157 | outl-=i; | ||
| 158 | ctx->buf_off+=i; | ||
| 159 | if (ctx->buf_len == ctx->buf_off) | ||
| 160 | { | ||
| 161 | ctx->buf_len=0; | ||
| 162 | ctx->buf_off=0; | ||
| 163 | } | ||
| 164 | } | ||
| 165 | |||
| 166 | /* At this point, we have room of outl bytes and an empty | ||
| 167 | * buffer, so we should read in some more. */ | ||
| 168 | |||
| 169 | while (outl > 0) | ||
| 170 | { | ||
| 171 | if (ctx->cont <= 0) break; | ||
| 172 | |||
| 173 | /* read in at offset 8, read the EVP_Cipher | ||
| 174 | * documentation about why */ | ||
| 175 | i=BIO_read(b->next_bio,&(ctx->buf[8]),ENC_BLOCK_SIZE); | ||
| 176 | |||
| 177 | if (i <= 0) | ||
| 178 | { | ||
| 179 | /* Should be continue next time we are called? */ | ||
| 180 | if (!BIO_should_retry(b->next_bio)) | ||
| 181 | { | ||
| 182 | ctx->cont=i; | ||
| 183 | i=EVP_CipherFinal(&(ctx->cipher), | ||
| 184 | (unsigned char *)ctx->buf, | ||
| 185 | &(ctx->buf_len)); | ||
| 186 | ctx->ok=i; | ||
| 187 | ctx->buf_off=0; | ||
| 188 | } | ||
| 189 | else | ||
| 190 | { | ||
| 191 | ret=(ret == 0)?i:ret; | ||
| 192 | break; | ||
| 193 | } | ||
| 194 | } | ||
| 195 | else | ||
| 196 | { | ||
| 197 | EVP_CipherUpdate(&(ctx->cipher), | ||
| 198 | (unsigned char *)ctx->buf,&ctx->buf_len, | ||
| 199 | (unsigned char *)&(ctx->buf[8]),i); | ||
| 200 | ctx->cont=1; | ||
| 201 | /* Note: it is possible for EVP_CipherUpdate to | ||
| 202 | * decrypt zero bytes because this is or looks like | ||
| 203 | * the final block: if this happens we should retry | ||
| 204 | * and either read more data or decrypt the final | ||
| 205 | * block | ||
| 206 | */ | ||
| 207 | if(ctx->buf_len == 0) continue; | ||
| 208 | } | ||
| 209 | |||
| 210 | if (ctx->buf_len <= outl) | ||
| 211 | i=ctx->buf_len; | ||
| 212 | else | ||
| 213 | i=outl; | ||
| 214 | if (i <= 0) break; | ||
| 215 | memcpy(out,ctx->buf,i); | ||
| 216 | ret+=i; | ||
| 217 | ctx->buf_off=i; | ||
| 218 | outl-=i; | ||
| 219 | out+=i; | ||
| 220 | } | ||
| 221 | |||
| 222 | BIO_clear_retry_flags(b); | ||
| 223 | BIO_copy_next_retry(b); | ||
| 224 | return((ret == 0)?ctx->cont:ret); | ||
| 225 | } | ||
| 226 | |||
| 227 | static int enc_write(BIO *b, char *in, int inl) | ||
| 228 | { | ||
| 229 | int ret=0,n,i; | ||
| 230 | BIO_ENC_CTX *ctx; | ||
| 231 | |||
| 232 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
| 233 | ret=inl; | ||
| 234 | |||
| 235 | BIO_clear_retry_flags(b); | ||
| 236 | n=ctx->buf_len-ctx->buf_off; | ||
| 237 | while (n > 0) | ||
| 238 | { | ||
| 239 | i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); | ||
| 240 | if (i <= 0) | ||
| 241 | { | ||
| 242 | BIO_copy_next_retry(b); | ||
| 243 | return(i); | ||
| 244 | } | ||
| 245 | ctx->buf_off+=i; | ||
| 246 | n-=i; | ||
| 247 | } | ||
| 248 | /* at this point all pending data has been written */ | ||
| 249 | |||
| 250 | if ((in == NULL) || (inl <= 0)) return(0); | ||
| 251 | |||
| 252 | ctx->buf_off=0; | ||
| 253 | while (inl > 0) | ||
| 254 | { | ||
| 255 | n=(inl > ENC_BLOCK_SIZE)?ENC_BLOCK_SIZE:inl; | ||
| 256 | EVP_CipherUpdate(&(ctx->cipher), | ||
| 257 | (unsigned char *)ctx->buf,&ctx->buf_len, | ||
| 258 | (unsigned char *)in,n); | ||
| 259 | inl-=n; | ||
| 260 | in+=n; | ||
| 261 | |||
| 262 | ctx->buf_off=0; | ||
| 263 | n=ctx->buf_len; | ||
| 264 | while (n > 0) | ||
| 265 | { | ||
| 266 | i=BIO_write(b->next_bio,&(ctx->buf[ctx->buf_off]),n); | ||
| 267 | if (i <= 0) | ||
| 268 | { | ||
| 269 | BIO_copy_next_retry(b); | ||
| 270 | return(i); | ||
| 271 | } | ||
| 272 | n-=i; | ||
| 273 | ctx->buf_off+=i; | ||
| 274 | } | ||
| 275 | ctx->buf_len=0; | ||
| 276 | ctx->buf_off=0; | ||
| 277 | } | ||
| 278 | BIO_copy_next_retry(b); | ||
| 279 | return(ret); | ||
| 280 | } | ||
| 281 | |||
| 282 | static long enc_ctrl(BIO *b, int cmd, long num, char *ptr) | ||
| 283 | { | ||
| 284 | BIO *dbio; | ||
| 285 | BIO_ENC_CTX *ctx,*dctx; | ||
| 286 | long ret=1; | ||
| 287 | int i; | ||
| 288 | EVP_CIPHER_CTX **c_ctx; | ||
| 289 | |||
| 290 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
| 291 | |||
| 292 | switch (cmd) | ||
| 293 | { | ||
| 294 | case BIO_CTRL_RESET: | ||
| 295 | ctx->ok=1; | ||
| 296 | ctx->finished=0; | ||
| 297 | EVP_CipherInit(&(ctx->cipher),NULL,NULL,NULL, | ||
| 298 | ctx->cipher.encrypt); | ||
| 299 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 300 | break; | ||
| 301 | case BIO_CTRL_EOF: /* More to read */ | ||
| 302 | if (ctx->cont <= 0) | ||
| 303 | ret=1; | ||
| 304 | else | ||
| 305 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 306 | break; | ||
| 307 | case BIO_CTRL_WPENDING: | ||
| 308 | ret=ctx->buf_len-ctx->buf_off; | ||
| 309 | if (ret <= 0) | ||
| 310 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 311 | break; | ||
| 312 | case BIO_CTRL_PENDING: /* More to read in buffer */ | ||
| 313 | ret=ctx->buf_len-ctx->buf_off; | ||
| 314 | if (ret <= 0) | ||
| 315 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 316 | break; | ||
| 317 | case BIO_CTRL_FLUSH: | ||
| 318 | /* do a final write */ | ||
| 319 | again: | ||
| 320 | while (ctx->buf_len != ctx->buf_off) | ||
| 321 | { | ||
| 322 | i=enc_write(b,NULL,0); | ||
| 323 | if (i < 0) | ||
| 324 | { | ||
| 325 | ret=i; | ||
| 326 | break; | ||
| 327 | } | ||
| 328 | } | ||
| 329 | |||
| 330 | if (!ctx->finished) | ||
| 331 | { | ||
| 332 | ctx->finished=1; | ||
| 333 | ctx->buf_off=0; | ||
| 334 | ret=EVP_CipherFinal(&(ctx->cipher), | ||
| 335 | (unsigned char *)ctx->buf, | ||
| 336 | &(ctx->buf_len)); | ||
| 337 | ctx->ok=(int)ret; | ||
| 338 | if (ret <= 0) break; | ||
| 339 | |||
| 340 | /* push out the bytes */ | ||
| 341 | goto again; | ||
| 342 | } | ||
| 343 | |||
| 344 | /* Finally flush the underlying BIO */ | ||
| 345 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 346 | break; | ||
| 347 | case BIO_C_GET_CIPHER_STATUS: | ||
| 348 | ret=(long)ctx->ok; | ||
| 349 | break; | ||
| 350 | case BIO_C_DO_STATE_MACHINE: | ||
| 351 | BIO_clear_retry_flags(b); | ||
| 352 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 353 | BIO_copy_next_retry(b); | ||
| 354 | break; | ||
| 355 | case BIO_C_GET_CIPHER_CTX: | ||
| 356 | c_ctx=(EVP_CIPHER_CTX **)ptr; | ||
| 357 | (*c_ctx)= &(ctx->cipher); | ||
| 358 | b->init=1; | ||
| 359 | break; | ||
| 360 | case BIO_CTRL_DUP: | ||
| 361 | dbio=(BIO *)ptr; | ||
| 362 | dctx=(BIO_ENC_CTX *)dbio->ptr; | ||
| 363 | memcpy(&(dctx->cipher),&(ctx->cipher),sizeof(ctx->cipher)); | ||
| 364 | dbio->init=1; | ||
| 365 | break; | ||
| 366 | default: | ||
| 367 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 368 | break; | ||
| 369 | } | ||
| 370 | return(ret); | ||
| 371 | } | ||
| 372 | |||
| 373 | static long enc_callback_ctrl(BIO *b, int cmd, void (*fp)()) | ||
| 374 | { | ||
| 375 | long ret=1; | ||
| 376 | |||
| 377 | if (b->next_bio == NULL) return(0); | ||
| 378 | switch (cmd) | ||
| 379 | { | ||
| 380 | default: | ||
| 381 | ret=BIO_callback_ctrl(b->next_bio,cmd,fp); | ||
| 382 | break; | ||
| 383 | } | ||
| 384 | return(ret); | ||
| 385 | } | ||
| 386 | |||
| 387 | /* | ||
| 388 | void BIO_set_cipher_ctx(b,c) | ||
| 389 | BIO *b; | ||
| 390 | EVP_CIPHER_ctx *c; | ||
| 391 | { | ||
| 392 | if (b == NULL) return; | ||
| 393 | |||
| 394 | if ((b->callback != NULL) && | ||
| 395 | (b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,0L) <= 0)) | ||
| 396 | return; | ||
| 397 | |||
| 398 | b->init=1; | ||
| 399 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
| 400 | memcpy(ctx->cipher,c,sizeof(EVP_CIPHER_CTX)); | ||
| 401 | |||
| 402 | if (b->callback != NULL) | ||
| 403 | b->callback(b,BIO_CB_CTRL,(char *)c,BIO_CTRL_SET,e,1L); | ||
| 404 | } | ||
| 405 | */ | ||
| 406 | |||
| 407 | void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, unsigned char *k, | ||
| 408 | unsigned char *i, int e) | ||
| 409 | { | ||
| 410 | BIO_ENC_CTX *ctx; | ||
| 411 | |||
| 412 | if (b == NULL) return; | ||
| 413 | |||
| 414 | if ((b->callback != NULL) && | ||
| 415 | (b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,0L) <= 0)) | ||
| 416 | return; | ||
| 417 | |||
| 418 | b->init=1; | ||
| 419 | ctx=(BIO_ENC_CTX *)b->ptr; | ||
| 420 | EVP_CipherInit(&(ctx->cipher),c,k,i,e); | ||
| 421 | |||
| 422 | if (b->callback != NULL) | ||
| 423 | b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,1L); | ||
| 424 | } | ||
| 425 | |||
diff --git a/src/lib/libcrypto/evp/bio_md.c b/src/lib/libcrypto/evp/bio_md.c deleted file mode 100644 index aef928dd8f..0000000000 --- a/src/lib/libcrypto/evp/bio_md.c +++ /dev/null | |||
| @@ -1,261 +0,0 @@ | |||
| 1 | /* crypto/evp/bio_md.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <errno.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/buffer.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | |||
| 65 | /* BIO_put and BIO_get both add to the digest, | ||
| 66 | * BIO_gets returns the digest */ | ||
| 67 | |||
| 68 | static int md_write(BIO *h,char *buf,int num); | ||
| 69 | static int md_read(BIO *h,char *buf,int size); | ||
| 70 | /*static int md_puts(BIO *h,char *str); */ | ||
| 71 | static int md_gets(BIO *h,char *str,int size); | ||
| 72 | static long md_ctrl(BIO *h,int cmd,long arg1,char *arg2); | ||
| 73 | static int md_new(BIO *h); | ||
| 74 | static int md_free(BIO *data); | ||
| 75 | static long md_callback_ctrl(BIO *h,int cmd,void (*fp)()); | ||
| 76 | |||
| 77 | static BIO_METHOD methods_md= | ||
| 78 | { | ||
| 79 | BIO_TYPE_MD,"message digest", | ||
| 80 | md_write, | ||
| 81 | md_read, | ||
| 82 | NULL, /* md_puts, */ | ||
| 83 | md_gets, | ||
| 84 | md_ctrl, | ||
| 85 | md_new, | ||
| 86 | md_free, | ||
| 87 | md_callback_ctrl, | ||
| 88 | }; | ||
| 89 | |||
| 90 | BIO_METHOD *BIO_f_md(void) | ||
| 91 | { | ||
| 92 | return(&methods_md); | ||
| 93 | } | ||
| 94 | |||
| 95 | static int md_new(BIO *bi) | ||
| 96 | { | ||
| 97 | EVP_MD_CTX *ctx; | ||
| 98 | |||
| 99 | ctx=(EVP_MD_CTX *)Malloc(sizeof(EVP_MD_CTX)); | ||
| 100 | if (ctx == NULL) return(0); | ||
| 101 | |||
| 102 | bi->init=0; | ||
| 103 | bi->ptr=(char *)ctx; | ||
| 104 | bi->flags=0; | ||
| 105 | return(1); | ||
| 106 | } | ||
| 107 | |||
| 108 | static int md_free(BIO *a) | ||
| 109 | { | ||
| 110 | if (a == NULL) return(0); | ||
| 111 | Free(a->ptr); | ||
| 112 | a->ptr=NULL; | ||
| 113 | a->init=0; | ||
| 114 | a->flags=0; | ||
| 115 | return(1); | ||
| 116 | } | ||
| 117 | |||
| 118 | static int md_read(BIO *b, char *out, int outl) | ||
| 119 | { | ||
| 120 | int ret=0; | ||
| 121 | EVP_MD_CTX *ctx; | ||
| 122 | |||
| 123 | if (out == NULL) return(0); | ||
| 124 | ctx=(EVP_MD_CTX *)b->ptr; | ||
| 125 | |||
| 126 | if ((ctx == NULL) || (b->next_bio == NULL)) return(0); | ||
| 127 | |||
| 128 | ret=BIO_read(b->next_bio,out,outl); | ||
| 129 | if (b->init) | ||
| 130 | { | ||
| 131 | if (ret > 0) | ||
| 132 | { | ||
| 133 | EVP_DigestUpdate(ctx,(unsigned char *)out, | ||
| 134 | (unsigned int)ret); | ||
| 135 | } | ||
| 136 | } | ||
| 137 | BIO_clear_retry_flags(b); | ||
| 138 | BIO_copy_next_retry(b); | ||
| 139 | return(ret); | ||
| 140 | } | ||
| 141 | |||
| 142 | static int md_write(BIO *b, char *in, int inl) | ||
| 143 | { | ||
| 144 | int ret=0; | ||
| 145 | EVP_MD_CTX *ctx; | ||
| 146 | |||
| 147 | if ((in == NULL) || (inl <= 0)) return(0); | ||
| 148 | ctx=(EVP_MD_CTX *)b->ptr; | ||
| 149 | |||
| 150 | if ((ctx != NULL) && (b->next_bio != NULL)) | ||
| 151 | ret=BIO_write(b->next_bio,in,inl); | ||
| 152 | if (b->init) | ||
| 153 | { | ||
| 154 | if (ret > 0) | ||
| 155 | { | ||
| 156 | EVP_DigestUpdate(ctx,(unsigned char *)in, | ||
| 157 | (unsigned int)ret); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | BIO_clear_retry_flags(b); | ||
| 161 | BIO_copy_next_retry(b); | ||
| 162 | return(ret); | ||
| 163 | } | ||
| 164 | |||
| 165 | static long md_ctrl(BIO *b, int cmd, long num, char *ptr) | ||
| 166 | { | ||
| 167 | EVP_MD_CTX *ctx,*dctx,**pctx; | ||
| 168 | const EVP_MD **ppmd; | ||
| 169 | EVP_MD *md; | ||
| 170 | long ret=1; | ||
| 171 | BIO *dbio; | ||
| 172 | |||
| 173 | ctx=(EVP_MD_CTX *)b->ptr; | ||
| 174 | |||
| 175 | switch (cmd) | ||
| 176 | { | ||
| 177 | case BIO_CTRL_RESET: | ||
| 178 | if (b->init) | ||
| 179 | EVP_DigestInit(ctx,ctx->digest); | ||
| 180 | else | ||
| 181 | ret=0; | ||
| 182 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 183 | break; | ||
| 184 | case BIO_C_GET_MD: | ||
| 185 | if (b->init) | ||
| 186 | { | ||
| 187 | ppmd=(const EVP_MD **)ptr; | ||
| 188 | *ppmd=ctx->digest; | ||
| 189 | } | ||
| 190 | else | ||
| 191 | ret=0; | ||
| 192 | break; | ||
| 193 | case BIO_C_GET_MD_CTX: | ||
| 194 | if (b->init) | ||
| 195 | { | ||
| 196 | pctx=(EVP_MD_CTX **)ptr; | ||
| 197 | *pctx=ctx; | ||
| 198 | } | ||
| 199 | else | ||
| 200 | ret=0; | ||
| 201 | break; | ||
| 202 | case BIO_C_DO_STATE_MACHINE: | ||
| 203 | BIO_clear_retry_flags(b); | ||
| 204 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 205 | BIO_copy_next_retry(b); | ||
| 206 | break; | ||
| 207 | |||
| 208 | case BIO_C_SET_MD: | ||
| 209 | md=(EVP_MD *)ptr; | ||
| 210 | EVP_DigestInit(ctx,md); | ||
| 211 | b->init=1; | ||
| 212 | break; | ||
| 213 | case BIO_CTRL_DUP: | ||
| 214 | dbio=(BIO *)ptr; | ||
| 215 | dctx=(EVP_MD_CTX *)dbio->ptr; | ||
| 216 | memcpy(dctx,ctx,sizeof(ctx)); | ||
| 217 | b->init=1; | ||
| 218 | break; | ||
| 219 | default: | ||
| 220 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 221 | break; | ||
| 222 | } | ||
| 223 | return(ret); | ||
| 224 | } | ||
| 225 | |||
| 226 | static long md_callback_ctrl(BIO *b, int cmd, void (*fp)()) | ||
| 227 | { | ||
| 228 | long ret=1; | ||
| 229 | |||
| 230 | if (b->next_bio == NULL) return(0); | ||
| 231 | switch (cmd) | ||
| 232 | { | ||
| 233 | default: | ||
| 234 | ret=BIO_callback_ctrl(b->next_bio,cmd,fp); | ||
| 235 | break; | ||
| 236 | } | ||
| 237 | return(ret); | ||
| 238 | } | ||
| 239 | |||
| 240 | static int md_gets(BIO *bp, char *buf, int size) | ||
| 241 | { | ||
| 242 | EVP_MD_CTX *ctx; | ||
| 243 | unsigned int ret; | ||
| 244 | |||
| 245 | |||
| 246 | ctx=(EVP_MD_CTX *)bp->ptr; | ||
| 247 | if (size < ctx->digest->md_size) | ||
| 248 | return(0); | ||
| 249 | EVP_DigestFinal(ctx,(unsigned char *)buf,&ret); | ||
| 250 | return((int)ret); | ||
| 251 | } | ||
| 252 | |||
| 253 | /* | ||
| 254 | static int md_puts(bp,str) | ||
| 255 | BIO *bp; | ||
| 256 | char *str; | ||
| 257 | { | ||
| 258 | return(-1); | ||
| 259 | } | ||
| 260 | */ | ||
| 261 | |||
diff --git a/src/lib/libcrypto/evp/c_all.c b/src/lib/libcrypto/evp/c_all.c deleted file mode 100644 index 1e185830a3..0000000000 --- a/src/lib/libcrypto/evp/c_all.c +++ /dev/null | |||
| @@ -1,67 +0,0 @@ | |||
| 1 | /* crypto/evp/c_all.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | |||
| 63 | void OpenSSL_add_all_algorithms(void) | ||
| 64 | { | ||
| 65 | OpenSSL_add_all_ciphers(); | ||
| 66 | OpenSSL_add_all_digests(); | ||
| 67 | } | ||
diff --git a/src/lib/libcrypto/evp/digest.c b/src/lib/libcrypto/evp/digest.c deleted file mode 100644 index c560733568..0000000000 --- a/src/lib/libcrypto/evp/digest.c +++ /dev/null | |||
| @@ -1,92 +0,0 @@ | |||
| 1 | /* crypto/evp/digest.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/objects.h> | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | |||
| 64 | void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type) | ||
| 65 | { | ||
| 66 | ctx->digest=type; | ||
| 67 | type->init(&(ctx->md)); | ||
| 68 | } | ||
| 69 | |||
| 70 | void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, | ||
| 71 | unsigned int count) | ||
| 72 | { | ||
| 73 | ctx->digest->update(&(ctx->md.base[0]),data,(unsigned long)count); | ||
| 74 | } | ||
| 75 | |||
| 76 | void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size) | ||
| 77 | { | ||
| 78 | ctx->digest->final(md,&(ctx->md.base[0])); | ||
| 79 | if (size != NULL) | ||
| 80 | *size=ctx->digest->md_size; | ||
| 81 | memset(&(ctx->md),0,sizeof(ctx->md)); | ||
| 82 | } | ||
| 83 | |||
| 84 | int EVP_MD_CTX_copy(EVP_MD_CTX *out, EVP_MD_CTX *in) | ||
| 85 | { | ||
| 86 | if ((in == NULL) || (in->digest == NULL)) { | ||
| 87 | EVPerr(EVP_F_EVP_MD_CTX_COPY,EVP_R_INPUT_NOT_INITIALIZED); | ||
| 88 | return 0; | ||
| 89 | } | ||
| 90 | memcpy((char *)out,(char *)in,in->digest->ctx_size); | ||
| 91 | return 1; | ||
| 92 | } | ||
diff --git a/src/lib/libcrypto/evp/e_null.c b/src/lib/libcrypto/evp/e_null.c deleted file mode 100644 index 0a62c10aa9..0000000000 --- a/src/lib/libcrypto/evp/e_null.c +++ /dev/null | |||
| @@ -1,97 +0,0 @@ | |||
| 1 | /* crypto/evp/e_null.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | |||
| 64 | static void null_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 65 | unsigned char *iv,int enc); | ||
| 66 | static void null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 67 | unsigned char *in, unsigned int inl); | ||
| 68 | static EVP_CIPHER n_cipher= | ||
| 69 | { | ||
| 70 | NID_undef, | ||
| 71 | 1,0,0, | ||
| 72 | null_init_key, | ||
| 73 | null_cipher, | ||
| 74 | NULL, | ||
| 75 | 0, | ||
| 76 | NULL, | ||
| 77 | NULL, | ||
| 78 | }; | ||
| 79 | |||
| 80 | EVP_CIPHER *EVP_enc_null(void) | ||
| 81 | { | ||
| 82 | return(&n_cipher); | ||
| 83 | } | ||
| 84 | |||
| 85 | static void null_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 86 | unsigned char *iv, int enc) | ||
| 87 | { | ||
| 88 | memset(&(ctx->c),0,sizeof(ctx->c)); | ||
| 89 | } | ||
| 90 | |||
| 91 | static void null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 92 | unsigned char *in, unsigned int inl) | ||
| 93 | { | ||
| 94 | if (in != out) | ||
| 95 | memcpy((char *)out,(char *)in,(int)inl); | ||
| 96 | } | ||
| 97 | |||
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c deleted file mode 100644 index c7e58a75cc..0000000000 --- a/src/lib/libcrypto/evp/e_rc4.c +++ /dev/null | |||
| @@ -1,115 +0,0 @@ | |||
| 1 | /* crypto/evp/e_rc4.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RC4 | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/objects.h> | ||
| 65 | |||
| 66 | static void rc4_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 67 | unsigned char *iv,int enc); | ||
| 68 | static void rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 69 | unsigned char *in, unsigned int inl); | ||
| 70 | static EVP_CIPHER r4_cipher= | ||
| 71 | { | ||
| 72 | NID_rc4, | ||
| 73 | 1,EVP_RC4_KEY_SIZE,0, | ||
| 74 | rc4_init_key, | ||
| 75 | rc4_cipher, | ||
| 76 | NULL, | ||
| 77 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 78 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)), | ||
| 79 | NULL, | ||
| 80 | NULL, | ||
| 81 | }; | ||
| 82 | |||
| 83 | static EVP_CIPHER r4_40_cipher= | ||
| 84 | { | ||
| 85 | NID_rc4_40, | ||
| 86 | 1,5 /* 40 bit */,0, | ||
| 87 | rc4_init_key, | ||
| 88 | rc4_cipher, | ||
| 89 | }; | ||
| 90 | |||
| 91 | EVP_CIPHER *EVP_rc4(void) | ||
| 92 | { | ||
| 93 | return(&r4_cipher); | ||
| 94 | } | ||
| 95 | |||
| 96 | EVP_CIPHER *EVP_rc4_40(void) | ||
| 97 | { | ||
| 98 | return(&r4_40_cipher); | ||
| 99 | } | ||
| 100 | |||
| 101 | static void rc4_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 102 | unsigned char *iv, int enc) | ||
| 103 | { | ||
| 104 | if (key != NULL) | ||
| 105 | memcpy(&(ctx->c.rc4.key[0]),key,EVP_CIPHER_CTX_key_length(ctx)); | ||
| 106 | RC4_set_key(&(ctx->c.rc4.ks),EVP_CIPHER_CTX_key_length(ctx), | ||
| 107 | ctx->c.rc4.key); | ||
| 108 | } | ||
| 109 | |||
| 110 | static void rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 111 | unsigned char *in, unsigned int inl) | ||
| 112 | { | ||
| 113 | RC4(&(ctx->c.rc4.ks),inl,in,out); | ||
| 114 | } | ||
| 115 | #endif | ||
diff --git a/src/lib/libcrypto/evp/e_xcbc_d.c b/src/lib/libcrypto/evp/e_xcbc_d.c deleted file mode 100644 index 7568fad4ff..0000000000 --- a/src/lib/libcrypto/evp/e_xcbc_d.c +++ /dev/null | |||
| @@ -1,112 +0,0 @@ | |||
| 1 | /* crypto/evp/e_xcbc_d.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_DES | ||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | #include <openssl/objects.h> | ||
| 64 | |||
| 65 | static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 66 | unsigned char *iv,int enc); | ||
| 67 | static void desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 68 | unsigned char *in, unsigned int inl); | ||
| 69 | static EVP_CIPHER d_xcbc_cipher= | ||
| 70 | { | ||
| 71 | NID_desx_cbc, | ||
| 72 | 8,24,8, | ||
| 73 | desx_cbc_init_key, | ||
| 74 | desx_cbc_cipher, | ||
| 75 | NULL, | ||
| 76 | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+ | ||
| 77 | sizeof((((EVP_CIPHER_CTX *)NULL)->c.desx_cbc)), | ||
| 78 | EVP_CIPHER_set_asn1_iv, | ||
| 79 | EVP_CIPHER_get_asn1_iv, | ||
| 80 | }; | ||
| 81 | |||
| 82 | EVP_CIPHER *EVP_desx_cbc(void) | ||
| 83 | { | ||
| 84 | return(&d_xcbc_cipher); | ||
| 85 | } | ||
| 86 | |||
| 87 | static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, | ||
| 88 | unsigned char *iv, int enc) | ||
| 89 | { | ||
| 90 | des_cblock *deskey = (des_cblock *)key; | ||
| 91 | |||
| 92 | if (iv != NULL) | ||
| 93 | memcpy(&(ctx->oiv[0]),iv,8); | ||
| 94 | memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); | ||
| 95 | if (deskey != NULL) | ||
| 96 | { | ||
| 97 | des_set_key_unchecked(deskey,ctx->c.desx_cbc.ks); | ||
| 98 | memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); | ||
| 99 | memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | static void desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 104 | unsigned char *in, unsigned int inl) | ||
| 105 | { | ||
| 106 | des_xcbc_encrypt(in,out,inl,ctx->c.desx_cbc.ks, | ||
| 107 | (des_cblock *)&(ctx->iv[0]), | ||
| 108 | &ctx->c.desx_cbc.inw, | ||
| 109 | &ctx->c.desx_cbc.outw, | ||
| 110 | ctx->encrypt); | ||
| 111 | } | ||
| 112 | #endif | ||
diff --git a/src/lib/libcrypto/evp/encode.c b/src/lib/libcrypto/evp/encode.c deleted file mode 100644 index 14a4cb11f6..0000000000 --- a/src/lib/libcrypto/evp/encode.c +++ /dev/null | |||
| @@ -1,427 +0,0 @@ | |||
| 1 | /* crypto/evp/encode.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | |||
| 63 | #ifndef CHARSET_EBCDIC | ||
| 64 | #define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f]) | ||
| 65 | #define conv_ascii2bin(a) (data_ascii2bin[(a)&0x7f]) | ||
| 66 | #else | ||
| 67 | /* We assume that PEM encoded files are EBCDIC files | ||
| 68 | * (i.e., printable text files). Convert them here while decoding. | ||
| 69 | * When encoding, output is EBCDIC (text) format again. | ||
| 70 | * (No need for conversion in the conv_bin2ascii macro, as the | ||
| 71 | * underlying textstring data_bin2ascii[] is already EBCDIC) | ||
| 72 | */ | ||
| 73 | #define conv_bin2ascii(a) (data_bin2ascii[(a)&0x3f]) | ||
| 74 | #define conv_ascii2bin(a) (data_ascii2bin[os_toascii[a]&0x7f]) | ||
| 75 | #endif | ||
| 76 | |||
| 77 | /* 64 char lines | ||
| 78 | * pad input with 0 | ||
| 79 | * left over chars are set to = | ||
| 80 | * 1 byte => xx== | ||
| 81 | * 2 bytes => xxx= | ||
| 82 | * 3 bytes => xxxx | ||
| 83 | */ | ||
| 84 | #define BIN_PER_LINE (64/4*3) | ||
| 85 | #define CHUNKS_PER_LINE (64/4) | ||
| 86 | #define CHAR_PER_LINE (64+1) | ||
| 87 | |||
| 88 | static unsigned char data_bin2ascii[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZ\ | ||
| 89 | abcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
| 90 | |||
| 91 | /* 0xF0 is a EOLN | ||
| 92 | * 0xF1 is ignore but next needs to be 0xF0 (for \r\n processing). | ||
| 93 | * 0xF2 is EOF | ||
| 94 | * 0xE0 is ignore at start of line. | ||
| 95 | * 0xFF is error | ||
| 96 | */ | ||
| 97 | |||
| 98 | #define B64_EOLN 0xF0 | ||
| 99 | #define B64_CR 0xF1 | ||
| 100 | #define B64_EOF 0xF2 | ||
| 101 | #define B64_WS 0xE0 | ||
| 102 | #define B64_ERROR 0xFF | ||
| 103 | #define B64_NOT_BASE64(a) (((a)|0x13) == 0xF3) | ||
| 104 | |||
| 105 | static unsigned char data_ascii2bin[128]={ | ||
| 106 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 107 | 0xFF,0xE0,0xF0,0xFF,0xFF,0xF1,0xFF,0xFF, | ||
| 108 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 109 | 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 110 | 0xE0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 111 | 0xFF,0xFF,0xFF,0x3E,0xFF,0xF2,0xFF,0x3F, | ||
| 112 | 0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B, | ||
| 113 | 0x3C,0x3D,0xFF,0xFF,0xFF,0x00,0xFF,0xFF, | ||
| 114 | 0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06, | ||
| 115 | 0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E, | ||
| 116 | 0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16, | ||
| 117 | 0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 118 | 0xFF,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x20, | ||
| 119 | 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28, | ||
| 120 | 0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30, | ||
| 121 | 0x31,0x32,0x33,0xFF,0xFF,0xFF,0xFF,0xFF, | ||
| 122 | }; | ||
| 123 | |||
| 124 | void EVP_EncodeInit(EVP_ENCODE_CTX *ctx) | ||
| 125 | { | ||
| 126 | ctx->length=48; | ||
| 127 | ctx->num=0; | ||
| 128 | ctx->line_num=0; | ||
| 129 | } | ||
| 130 | |||
| 131 | void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | ||
| 132 | unsigned char *in, int inl) | ||
| 133 | { | ||
| 134 | int i,j; | ||
| 135 | unsigned int total=0; | ||
| 136 | |||
| 137 | *outl=0; | ||
| 138 | if (inl == 0) return; | ||
| 139 | if ((ctx->num+inl) < ctx->length) | ||
| 140 | { | ||
| 141 | memcpy(&(ctx->enc_data[ctx->num]),in,inl); | ||
| 142 | ctx->num+=inl; | ||
| 143 | return; | ||
| 144 | } | ||
| 145 | if (ctx->num != 0) | ||
| 146 | { | ||
| 147 | i=ctx->length-ctx->num; | ||
| 148 | memcpy(&(ctx->enc_data[ctx->num]),in,i); | ||
| 149 | in+=i; | ||
| 150 | inl-=i; | ||
| 151 | j=EVP_EncodeBlock(out,ctx->enc_data,ctx->length); | ||
| 152 | ctx->num=0; | ||
| 153 | out+=j; | ||
| 154 | *(out++)='\n'; | ||
| 155 | *out='\0'; | ||
| 156 | total=j+1; | ||
| 157 | } | ||
| 158 | while (inl >= ctx->length) | ||
| 159 | { | ||
| 160 | j=EVP_EncodeBlock(out,in,ctx->length); | ||
| 161 | in+=ctx->length; | ||
| 162 | inl-=ctx->length; | ||
| 163 | out+=j; | ||
| 164 | *(out++)='\n'; | ||
| 165 | *out='\0'; | ||
| 166 | total+=j+1; | ||
| 167 | } | ||
| 168 | if (inl != 0) | ||
| 169 | memcpy(&(ctx->enc_data[0]),in,inl); | ||
| 170 | ctx->num=inl; | ||
| 171 | *outl=total; | ||
| 172 | } | ||
| 173 | |||
| 174 | void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl) | ||
| 175 | { | ||
| 176 | unsigned int ret=0; | ||
| 177 | |||
| 178 | if (ctx->num != 0) | ||
| 179 | { | ||
| 180 | ret=EVP_EncodeBlock(out,ctx->enc_data,ctx->num); | ||
| 181 | out[ret++]='\n'; | ||
| 182 | out[ret]='\0'; | ||
| 183 | ctx->num=0; | ||
| 184 | } | ||
| 185 | *outl=ret; | ||
| 186 | } | ||
| 187 | |||
| 188 | int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int dlen) | ||
| 189 | { | ||
| 190 | int i,ret=0; | ||
| 191 | unsigned long l; | ||
| 192 | |||
| 193 | for (i=dlen; i > 0; i-=3) | ||
| 194 | { | ||
| 195 | if (i >= 3) | ||
| 196 | { | ||
| 197 | l= (((unsigned long)f[0])<<16L)| | ||
| 198 | (((unsigned long)f[1])<< 8L)|f[2]; | ||
| 199 | *(t++)=conv_bin2ascii(l>>18L); | ||
| 200 | *(t++)=conv_bin2ascii(l>>12L); | ||
| 201 | *(t++)=conv_bin2ascii(l>> 6L); | ||
| 202 | *(t++)=conv_bin2ascii(l ); | ||
| 203 | } | ||
| 204 | else | ||
| 205 | { | ||
| 206 | l=((unsigned long)f[0])<<16L; | ||
| 207 | if (i == 2) l|=((unsigned long)f[1]<<8L); | ||
| 208 | |||
| 209 | *(t++)=conv_bin2ascii(l>>18L); | ||
| 210 | *(t++)=conv_bin2ascii(l>>12L); | ||
| 211 | *(t++)=(i == 1)?'=':conv_bin2ascii(l>> 6L); | ||
| 212 | *(t++)='='; | ||
| 213 | } | ||
| 214 | ret+=4; | ||
| 215 | f+=3; | ||
| 216 | } | ||
| 217 | |||
| 218 | *t='\0'; | ||
| 219 | return(ret); | ||
| 220 | } | ||
| 221 | |||
| 222 | void EVP_DecodeInit(EVP_ENCODE_CTX *ctx) | ||
| 223 | { | ||
| 224 | ctx->length=30; | ||
| 225 | ctx->num=0; | ||
| 226 | ctx->line_num=0; | ||
| 227 | ctx->expect_nl=0; | ||
| 228 | } | ||
| 229 | |||
| 230 | /* -1 for error | ||
| 231 | * 0 for last line | ||
| 232 | * 1 for full line | ||
| 233 | */ | ||
| 234 | int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, | ||
| 235 | unsigned char *in, int inl) | ||
| 236 | { | ||
| 237 | int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2,exp_nl; | ||
| 238 | unsigned char *d; | ||
| 239 | |||
| 240 | n=ctx->num; | ||
| 241 | d=ctx->enc_data; | ||
| 242 | ln=ctx->line_num; | ||
| 243 | exp_nl=ctx->expect_nl; | ||
| 244 | |||
| 245 | /* last line of input. */ | ||
| 246 | if ((inl == 0) || ((n == 0) && (conv_ascii2bin(in[0]) == B64_EOF))) | ||
| 247 | { rv=0; goto end; } | ||
| 248 | |||
| 249 | /* We parse the input data */ | ||
| 250 | for (i=0; i<inl; i++) | ||
| 251 | { | ||
| 252 | /* If the current line is > 80 characters, scream alot */ | ||
| 253 | if (ln >= 80) { rv= -1; goto end; } | ||
| 254 | |||
| 255 | /* Get char and put it into the buffer */ | ||
| 256 | tmp= *(in++); | ||
| 257 | v=conv_ascii2bin(tmp); | ||
| 258 | /* only save the good data :-) */ | ||
| 259 | if (!B64_NOT_BASE64(v)) | ||
| 260 | { | ||
| 261 | d[n++]=tmp; | ||
| 262 | ln++; | ||
| 263 | } | ||
| 264 | else if (v == B64_ERROR) | ||
| 265 | { | ||
| 266 | rv= -1; | ||
| 267 | goto end; | ||
| 268 | } | ||
| 269 | |||
| 270 | /* have we seen a '=' which is 'definitly' the last | ||
| 271 | * input line. seof will point to the character that | ||
| 272 | * holds it. and eof will hold how many characters to | ||
| 273 | * chop off. */ | ||
| 274 | if (tmp == '=') | ||
| 275 | { | ||
| 276 | if (seof == -1) seof=n; | ||
| 277 | eof++; | ||
| 278 | } | ||
| 279 | |||
| 280 | /* eoln */ | ||
| 281 | if (v == B64_EOLN) | ||
| 282 | { | ||
| 283 | ln=0; | ||
| 284 | if (exp_nl) | ||
| 285 | { | ||
| 286 | exp_nl=0; | ||
| 287 | continue; | ||
| 288 | } | ||
| 289 | } | ||
| 290 | exp_nl=0; | ||
| 291 | |||
| 292 | /* If we are at the end of input and it looks like a | ||
| 293 | * line, process it. */ | ||
| 294 | if (((i+1) == inl) && (((n&3) == 0) || eof)) | ||
| 295 | v=B64_EOF; | ||
| 296 | |||
| 297 | if ((v == B64_EOF) || (n >= 64)) | ||
| 298 | { | ||
| 299 | /* This is needed to work correctly on 64 byte input | ||
| 300 | * lines. We process the line and then need to | ||
| 301 | * accept the '\n' */ | ||
| 302 | if ((v != B64_EOF) && (n >= 64)) exp_nl=1; | ||
| 303 | tmp2=v; | ||
| 304 | if (n > 0) | ||
| 305 | { | ||
| 306 | v=EVP_DecodeBlock(out,d,n); | ||
| 307 | if (v < 0) { rv=0; goto end; } | ||
| 308 | n=0; | ||
| 309 | ret+=(v-eof); | ||
| 310 | } | ||
| 311 | else | ||
| 312 | { | ||
| 313 | eof=1; | ||
| 314 | v=0; | ||
| 315 | } | ||
| 316 | |||
| 317 | /* This is the case where we have had a short | ||
| 318 | * but valid input line */ | ||
| 319 | if ((v < ctx->length) && eof) | ||
| 320 | { | ||
| 321 | rv=0; | ||
| 322 | goto end; | ||
| 323 | } | ||
| 324 | else | ||
| 325 | ctx->length=v; | ||
| 326 | |||
| 327 | if (seof >= 0) { rv=0; goto end; } | ||
| 328 | out+=v; | ||
| 329 | } | ||
| 330 | } | ||
| 331 | rv=1; | ||
| 332 | end: | ||
| 333 | *outl=ret; | ||
| 334 | ctx->num=n; | ||
| 335 | ctx->line_num=ln; | ||
| 336 | ctx->expect_nl=exp_nl; | ||
| 337 | return(rv); | ||
| 338 | } | ||
| 339 | |||
| 340 | int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n) | ||
| 341 | { | ||
| 342 | int i,ret=0,a,b,c,d; | ||
| 343 | unsigned long l; | ||
| 344 | |||
| 345 | /* trim white space from the start of the line. */ | ||
| 346 | while ((conv_ascii2bin(*f) == B64_WS) && (n > 0)) | ||
| 347 | { | ||
| 348 | f++; | ||
| 349 | n--; | ||
| 350 | } | ||
| 351 | |||
| 352 | /* strip off stuff at the end of the line | ||
| 353 | * ascii2bin values B64_WS, B64_EOLN, B64_EOLN and B64_EOF */ | ||
| 354 | while ((n > 3) && (B64_NOT_BASE64(conv_ascii2bin(f[n-1])))) | ||
| 355 | n--; | ||
| 356 | |||
| 357 | if (n%4 != 0) return(-1); | ||
| 358 | |||
| 359 | for (i=0; i<n; i+=4) | ||
| 360 | { | ||
| 361 | a=conv_ascii2bin(*(f++)); | ||
| 362 | b=conv_ascii2bin(*(f++)); | ||
| 363 | c=conv_ascii2bin(*(f++)); | ||
| 364 | d=conv_ascii2bin(*(f++)); | ||
| 365 | if ( (a & 0x80) || (b & 0x80) || | ||
| 366 | (c & 0x80) || (d & 0x80)) | ||
| 367 | return(-1); | ||
| 368 | l=( (((unsigned long)a)<<18L)| | ||
| 369 | (((unsigned long)b)<<12L)| | ||
| 370 | (((unsigned long)c)<< 6L)| | ||
| 371 | (((unsigned long)d) )); | ||
| 372 | *(t++)=(unsigned char)(l>>16L)&0xff; | ||
| 373 | *(t++)=(unsigned char)(l>> 8L)&0xff; | ||
| 374 | *(t++)=(unsigned char)(l )&0xff; | ||
| 375 | ret+=3; | ||
| 376 | } | ||
| 377 | return(ret); | ||
| 378 | } | ||
| 379 | |||
| 380 | int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl) | ||
| 381 | { | ||
| 382 | int i; | ||
| 383 | |||
| 384 | *outl=0; | ||
| 385 | if (ctx->num != 0) | ||
| 386 | { | ||
| 387 | i=EVP_DecodeBlock(out,ctx->enc_data,ctx->num); | ||
| 388 | if (i < 0) return(-1); | ||
| 389 | ctx->num=0; | ||
| 390 | *outl=i; | ||
| 391 | return(1); | ||
| 392 | } | ||
| 393 | else | ||
| 394 | return(1); | ||
| 395 | } | ||
| 396 | |||
| 397 | #ifdef undef | ||
| 398 | int EVP_DecodeValid(unsigned char *buf, int len) | ||
| 399 | { | ||
| 400 | int i,num=0,bad=0; | ||
| 401 | |||
| 402 | if (len == 0) return(-1); | ||
| 403 | while (conv_ascii2bin(*buf) == B64_WS) | ||
| 404 | { | ||
| 405 | buf++; | ||
| 406 | len--; | ||
| 407 | if (len == 0) return(-1); | ||
| 408 | } | ||
| 409 | |||
| 410 | for (i=len; i >= 4; i-=4) | ||
| 411 | { | ||
| 412 | if ( (conv_ascii2bin(buf[0]) >= 0x40) || | ||
| 413 | (conv_ascii2bin(buf[1]) >= 0x40) || | ||
| 414 | (conv_ascii2bin(buf[2]) >= 0x40) || | ||
| 415 | (conv_ascii2bin(buf[3]) >= 0x40)) | ||
| 416 | return(-1); | ||
| 417 | buf+=4; | ||
| 418 | num+=1+(buf[2] != '=')+(buf[3] != '='); | ||
| 419 | } | ||
| 420 | if ((i == 1) && (conv_ascii2bin(buf[0]) == B64_EOLN)) | ||
| 421 | return(num); | ||
| 422 | if ((i == 2) && (conv_ascii2bin(buf[0]) == B64_EOLN) && | ||
| 423 | (conv_ascii2bin(buf[0]) == B64_EOLN)) | ||
| 424 | return(num); | ||
| 425 | return(1); | ||
| 426 | } | ||
| 427 | #endif | ||
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h deleted file mode 100644 index 54215b0905..0000000000 --- a/src/lib/libcrypto/evp/evp.h +++ /dev/null | |||
| @@ -1,743 +0,0 @@ | |||
| 1 | /* crypto/evp/evp.h */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef HEADER_ENVELOPE_H | ||
| 60 | #define HEADER_ENVELOPE_H | ||
| 61 | |||
| 62 | #ifdef __cplusplus | ||
| 63 | extern "C" { | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #ifndef NO_MD2 | ||
| 67 | #include <openssl/md2.h> | ||
| 68 | #endif | ||
| 69 | #ifndef NO_MD5 | ||
| 70 | #include <openssl/md5.h> | ||
| 71 | #endif | ||
| 72 | #ifndef NO_SHA | ||
| 73 | #include <openssl/sha.h> | ||
| 74 | #endif | ||
| 75 | #ifndef NO_RIPEMD | ||
| 76 | #include <openssl/ripemd.h> | ||
| 77 | #endif | ||
| 78 | #ifndef NO_DES | ||
| 79 | #include <openssl/des.h> | ||
| 80 | #endif | ||
| 81 | #ifndef NO_RC4 | ||
| 82 | #include <openssl/rc4.h> | ||
| 83 | #endif | ||
| 84 | #ifndef NO_RC2 | ||
| 85 | #include <openssl/rc2.h> | ||
| 86 | #endif | ||
| 87 | #ifndef NO_RC5 | ||
| 88 | #include <openssl/rc5.h> | ||
| 89 | #endif | ||
| 90 | #ifndef NO_BF | ||
| 91 | #include <openssl/blowfish.h> | ||
| 92 | #endif | ||
| 93 | #ifndef NO_CAST | ||
| 94 | #include <openssl/cast.h> | ||
| 95 | #endif | ||
| 96 | #ifndef NO_IDEA | ||
| 97 | #include <openssl/idea.h> | ||
| 98 | #endif | ||
| 99 | #ifndef NO_MDC2 | ||
| 100 | #include <openssl/mdc2.h> | ||
| 101 | #endif | ||
| 102 | |||
| 103 | #define EVP_RC2_KEY_SIZE 16 | ||
| 104 | #define EVP_RC4_KEY_SIZE 16 | ||
| 105 | #define EVP_BLOWFISH_KEY_SIZE 16 | ||
| 106 | #define EVP_CAST5_KEY_SIZE 16 | ||
| 107 | #define EVP_RC5_32_12_16_KEY_SIZE 16 | ||
| 108 | #define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */ | ||
| 109 | #define EVP_MAX_KEY_LENGTH 24 | ||
| 110 | #define EVP_MAX_IV_LENGTH 8 | ||
| 111 | |||
| 112 | #define PKCS5_SALT_LEN 8 | ||
| 113 | /* Default PKCS#5 iteration count */ | ||
| 114 | #define PKCS5_DEFAULT_ITER 2048 | ||
| 115 | |||
| 116 | #ifndef NO_RSA | ||
| 117 | #include <openssl/rsa.h> | ||
| 118 | #endif | ||
| 119 | |||
| 120 | #ifndef NO_DSA | ||
| 121 | #include <openssl/dsa.h> | ||
| 122 | #endif | ||
| 123 | |||
| 124 | #ifndef NO_DH | ||
| 125 | #include <openssl/dh.h> | ||
| 126 | #endif | ||
| 127 | |||
| 128 | #include <openssl/objects.h> | ||
| 129 | |||
| 130 | #define EVP_PK_RSA 0x0001 | ||
| 131 | #define EVP_PK_DSA 0x0002 | ||
| 132 | #define EVP_PK_DH 0x0004 | ||
| 133 | #define EVP_PKT_SIGN 0x0010 | ||
| 134 | #define EVP_PKT_ENC 0x0020 | ||
| 135 | #define EVP_PKT_EXCH 0x0040 | ||
| 136 | #define EVP_PKS_RSA 0x0100 | ||
| 137 | #define EVP_PKS_DSA 0x0200 | ||
| 138 | #define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ | ||
| 139 | |||
| 140 | #define EVP_PKEY_NONE NID_undef | ||
| 141 | #define EVP_PKEY_RSA NID_rsaEncryption | ||
| 142 | #define EVP_PKEY_RSA2 NID_rsa | ||
| 143 | #define EVP_PKEY_DSA NID_dsa | ||
| 144 | #define EVP_PKEY_DSA1 NID_dsa_2 | ||
| 145 | #define EVP_PKEY_DSA2 NID_dsaWithSHA | ||
| 146 | #define EVP_PKEY_DSA3 NID_dsaWithSHA1 | ||
| 147 | #define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 | ||
| 148 | #define EVP_PKEY_DH NID_dhKeyAgreement | ||
| 149 | |||
| 150 | /* Type needs to be a bit field | ||
| 151 | * Sub-type needs to be for variations on the method, as in, can it do | ||
| 152 | * arbitrary encryption.... */ | ||
| 153 | typedef struct evp_pkey_st | ||
| 154 | { | ||
| 155 | int type; | ||
| 156 | int save_type; | ||
| 157 | int references; | ||
| 158 | union { | ||
| 159 | char *ptr; | ||
| 160 | #ifndef NO_RSA | ||
| 161 | struct rsa_st *rsa; /* RSA */ | ||
| 162 | #endif | ||
| 163 | #ifndef NO_DSA | ||
| 164 | struct dsa_st *dsa; /* DSA */ | ||
| 165 | #endif | ||
| 166 | #ifndef NO_DH | ||
| 167 | struct dh_st *dh; /* DH */ | ||
| 168 | #endif | ||
| 169 | } pkey; | ||
| 170 | int save_parameters; | ||
| 171 | STACK /*X509_ATTRIBUTE*/ *attributes; /* [ 0 ] */ | ||
| 172 | } EVP_PKEY; | ||
| 173 | |||
| 174 | #define EVP_PKEY_MO_SIGN 0x0001 | ||
| 175 | #define EVP_PKEY_MO_VERIFY 0x0002 | ||
| 176 | #define EVP_PKEY_MO_ENCRYPT 0x0004 | ||
| 177 | #define EVP_PKEY_MO_DECRYPT 0x0008 | ||
| 178 | |||
| 179 | #if 0 | ||
| 180 | /* This structure is required to tie the message digest and signing together. | ||
| 181 | * The lookup can be done by md/pkey_method, oid, oid/pkey_method, or | ||
| 182 | * oid, md and pkey. | ||
| 183 | * This is required because for various smart-card perform the digest and | ||
| 184 | * signing/verification on-board. To handle this case, the specific | ||
| 185 | * EVP_MD and EVP_PKEY_METHODs need to be closely associated. | ||
| 186 | * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it. | ||
| 187 | * This can either be software or a token to provide the required low level | ||
| 188 | * routines. | ||
| 189 | */ | ||
| 190 | typedef struct evp_pkey_md_st | ||
| 191 | { | ||
| 192 | int oid; | ||
| 193 | EVP_MD *md; | ||
| 194 | EVP_PKEY_METHOD *pkey; | ||
| 195 | } EVP_PKEY_MD; | ||
| 196 | |||
| 197 | #define EVP_rsa_md2() \ | ||
| 198 | EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\ | ||
| 199 | EVP_rsa_pkcs1(),EVP_md2()) | ||
| 200 | #define EVP_rsa_md5() \ | ||
| 201 | EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\ | ||
| 202 | EVP_rsa_pkcs1(),EVP_md5()) | ||
| 203 | #define EVP_rsa_sha0() \ | ||
| 204 | EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\ | ||
| 205 | EVP_rsa_pkcs1(),EVP_sha()) | ||
| 206 | #define EVP_rsa_sha1() \ | ||
| 207 | EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\ | ||
| 208 | EVP_rsa_pkcs1(),EVP_sha1()) | ||
| 209 | #define EVP_rsa_ripemd160() \ | ||
| 210 | EVP_PKEY_MD_add(NID_ripemd160WithRSA,\ | ||
| 211 | EVP_rsa_pkcs1(),EVP_ripemd160()) | ||
| 212 | #define EVP_rsa_mdc2() \ | ||
| 213 | EVP_PKEY_MD_add(NID_mdc2WithRSA,\ | ||
| 214 | EVP_rsa_octet_string(),EVP_mdc2()) | ||
| 215 | #define EVP_dsa_sha() \ | ||
| 216 | EVP_PKEY_MD_add(NID_dsaWithSHA,\ | ||
| 217 | EVP_dsa(),EVP_mdc2()) | ||
| 218 | #define EVP_dsa_sha1() \ | ||
| 219 | EVP_PKEY_MD_add(NID_dsaWithSHA1,\ | ||
| 220 | EVP_dsa(),EVP_sha1()) | ||
| 221 | |||
| 222 | typedef struct evp_pkey_method_st | ||
| 223 | { | ||
| 224 | char *name; | ||
| 225 | int flags; | ||
| 226 | int type; /* RSA, DSA, an SSLeay specific constant */ | ||
| 227 | int oid; /* For the pub-key type */ | ||
| 228 | int encrypt_oid; /* pub/priv key encryption */ | ||
| 229 | |||
| 230 | int (*sign)(); | ||
| 231 | int (*verify)(); | ||
| 232 | struct { | ||
| 233 | int | ||
| 234 | int (*set)(); /* get and/or set the underlying type */ | ||
| 235 | int (*get)(); | ||
| 236 | int (*encrypt)(); | ||
| 237 | int (*decrypt)(); | ||
| 238 | int (*i2d)(); | ||
| 239 | int (*d2i)(); | ||
| 240 | int (*dup)(); | ||
| 241 | } pub,priv; | ||
| 242 | int (*set_asn1_parameters)(); | ||
| 243 | int (*get_asn1_parameters)(); | ||
| 244 | } EVP_PKEY_METHOD; | ||
| 245 | #endif | ||
| 246 | |||
| 247 | #ifndef EVP_MD | ||
| 248 | typedef struct env_md_st | ||
| 249 | { | ||
| 250 | int type; | ||
| 251 | int pkey_type; | ||
| 252 | int md_size; | ||
| 253 | void (*init)(); | ||
| 254 | void (*update)(); | ||
| 255 | void (*final)(); | ||
| 256 | |||
| 257 | int (*sign)(); | ||
| 258 | int (*verify)(); | ||
| 259 | int required_pkey_type[5]; /*EVP_PKEY_xxx */ | ||
| 260 | int block_size; | ||
| 261 | int ctx_size; /* how big does the ctx need to be */ | ||
| 262 | } EVP_MD; | ||
| 263 | |||
| 264 | |||
| 265 | |||
| 266 | #define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} | ||
| 267 | |||
| 268 | #ifndef NO_DSA | ||
| 269 | #define EVP_PKEY_DSA_method DSA_sign,DSA_verify, \ | ||
| 270 | {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ | ||
| 271 | EVP_PKEY_DSA4,0} | ||
| 272 | #else | ||
| 273 | #define EVP_PKEY_DSA_method EVP_PKEY_NULL_method | ||
| 274 | #endif | ||
| 275 | |||
| 276 | #ifndef NO_RSA | ||
| 277 | #define EVP_PKEY_RSA_method RSA_sign,RSA_verify, \ | ||
| 278 | {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} | ||
| 279 | #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ | ||
| 280 | RSA_sign_ASN1_OCTET_STRING, \ | ||
| 281 | RSA_verify_ASN1_OCTET_STRING, \ | ||
| 282 | {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} | ||
| 283 | #else | ||
| 284 | #define EVP_PKEY_RSA_method EVP_PKEY_NULL_method | ||
| 285 | #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method | ||
| 286 | #endif | ||
| 287 | |||
| 288 | #endif /* !EVP_MD */ | ||
| 289 | |||
| 290 | typedef struct env_md_ctx_st | ||
| 291 | { | ||
| 292 | const EVP_MD *digest; | ||
| 293 | union { | ||
| 294 | unsigned char base[4]; | ||
| 295 | #ifndef NO_MD2 | ||
| 296 | MD2_CTX md2; | ||
| 297 | #endif | ||
| 298 | #ifndef NO_MD5 | ||
| 299 | MD5_CTX md5; | ||
| 300 | #endif | ||
| 301 | #ifndef NO_RIPEMD | ||
| 302 | RIPEMD160_CTX ripemd160; | ||
| 303 | #endif | ||
| 304 | #ifndef NO_SHA | ||
| 305 | SHA_CTX sha; | ||
| 306 | #endif | ||
| 307 | #ifndef NO_MDC2 | ||
| 308 | MDC2_CTX mdc2; | ||
| 309 | #endif | ||
| 310 | } md; | ||
| 311 | } EVP_MD_CTX; | ||
| 312 | |||
| 313 | typedef struct evp_cipher_st | ||
| 314 | { | ||
| 315 | int nid; | ||
| 316 | int block_size; | ||
| 317 | int key_len; | ||
| 318 | int iv_len; | ||
| 319 | void (*init)(); /* init for encryption */ | ||
| 320 | void (*do_cipher)(); /* encrypt data */ | ||
| 321 | void (*cleanup)(); /* used by cipher method */ | ||
| 322 | int ctx_size; /* how big the ctx needs to be */ | ||
| 323 | /* int set_asn1_parameters(EVP_CIPHER_CTX,ASN1_TYPE *); */ | ||
| 324 | int (*set_asn1_parameters)(); /* Populate a ASN1_TYPE with parameters */ | ||
| 325 | /* int get_asn1_parameters(EVP_CIPHER_CTX,ASN1_TYPE *); */ | ||
| 326 | int (*get_asn1_parameters)(); /* Get parameters from a ASN1_TYPE */ | ||
| 327 | } EVP_CIPHER; | ||
| 328 | |||
| 329 | typedef struct evp_cipher_info_st | ||
| 330 | { | ||
| 331 | const EVP_CIPHER *cipher; | ||
| 332 | unsigned char iv[EVP_MAX_IV_LENGTH]; | ||
| 333 | } EVP_CIPHER_INFO; | ||
| 334 | |||
| 335 | typedef struct evp_cipher_ctx_st | ||
| 336 | { | ||
| 337 | const EVP_CIPHER *cipher; | ||
| 338 | int encrypt; /* encrypt or decrypt */ | ||
| 339 | int buf_len; /* number we have left */ | ||
| 340 | |||
| 341 | unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ | ||
| 342 | unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ | ||
| 343 | unsigned char buf[EVP_MAX_IV_LENGTH]; /* saved partial block */ | ||
| 344 | int num; /* used by cfb/ofb mode */ | ||
| 345 | |||
| 346 | char *app_data; /* application stuff */ | ||
| 347 | union { | ||
| 348 | #ifndef NO_RC4 | ||
| 349 | struct | ||
| 350 | { | ||
| 351 | unsigned char key[EVP_RC4_KEY_SIZE]; | ||
| 352 | RC4_KEY ks; /* working key */ | ||
| 353 | } rc4; | ||
| 354 | #endif | ||
| 355 | #ifndef NO_DES | ||
| 356 | des_key_schedule des_ks;/* key schedule */ | ||
| 357 | struct | ||
| 358 | { | ||
| 359 | des_key_schedule ks;/* key schedule */ | ||
| 360 | des_cblock inw; | ||
| 361 | des_cblock outw; | ||
| 362 | } desx_cbc; | ||
| 363 | struct | ||
| 364 | { | ||
| 365 | des_key_schedule ks1;/* key schedule */ | ||
| 366 | des_key_schedule ks2;/* key schedule (for ede) */ | ||
| 367 | des_key_schedule ks3;/* key schedule (for ede3) */ | ||
| 368 | } des_ede; | ||
| 369 | #endif | ||
| 370 | #ifndef NO_IDEA | ||
| 371 | IDEA_KEY_SCHEDULE idea_ks;/* key schedule */ | ||
| 372 | #endif | ||
| 373 | #ifndef NO_RC2 | ||
| 374 | RC2_KEY rc2_ks;/* key schedule */ | ||
| 375 | #endif | ||
| 376 | #ifndef NO_RC5 | ||
| 377 | RC5_32_KEY rc5_ks;/* key schedule */ | ||
| 378 | #endif | ||
| 379 | #ifndef NO_BF | ||
| 380 | BF_KEY bf_ks;/* key schedule */ | ||
| 381 | #endif | ||
| 382 | #ifndef NO_CAST | ||
| 383 | CAST_KEY cast_ks;/* key schedule */ | ||
| 384 | #endif | ||
| 385 | } c; | ||
| 386 | } EVP_CIPHER_CTX; | ||
| 387 | |||
| 388 | typedef struct evp_Encode_Ctx_st | ||
| 389 | { | ||
| 390 | int num; /* number saved in a partial encode/decode */ | ||
| 391 | int length; /* The length is either the output line length | ||
| 392 | * (in input bytes) or the shortest input line | ||
| 393 | * length that is ok. Once decoding begins, | ||
| 394 | * the length is adjusted up each time a longer | ||
| 395 | * line is decoded */ | ||
| 396 | unsigned char enc_data[80]; /* data to encode */ | ||
| 397 | int line_num; /* number read on current line */ | ||
| 398 | int expect_nl; | ||
| 399 | } EVP_ENCODE_CTX; | ||
| 400 | |||
| 401 | /* Password based encryption function */ | ||
| 402 | typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | ||
| 403 | ASN1_TYPE *param, EVP_CIPHER *cipher, | ||
| 404 | EVP_MD *md, int en_de); | ||
| 405 | |||
| 406 | #define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ | ||
| 407 | (char *)(rsa)) | ||
| 408 | #define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ | ||
| 409 | (char *)(dsa)) | ||
| 410 | #define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ | ||
| 411 | (char *)(dh)) | ||
| 412 | |||
| 413 | /* Add some extra combinations */ | ||
| 414 | #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) | ||
| 415 | #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) | ||
| 416 | #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) | ||
| 417 | #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) | ||
| 418 | |||
| 419 | #define EVP_MD_type(e) ((e)->type) | ||
| 420 | #define EVP_MD_pkey_type(e) ((e)->pkey_type) | ||
| 421 | #define EVP_MD_size(e) ((e)->md_size) | ||
| 422 | #define EVP_MD_block_size(e) ((e)->block_size) | ||
| 423 | |||
| 424 | #define EVP_MD_CTX_md(e) ((e)->digest) | ||
| 425 | #define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) | ||
| 426 | #define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) | ||
| 427 | #define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) | ||
| 428 | |||
| 429 | #define EVP_CIPHER_nid(e) ((e)->nid) | ||
| 430 | #define EVP_CIPHER_block_size(e) ((e)->block_size) | ||
| 431 | #define EVP_CIPHER_key_length(e) ((e)->key_len) | ||
| 432 | #define EVP_CIPHER_iv_length(e) ((e)->iv_len) | ||
| 433 | |||
| 434 | #define EVP_CIPHER_CTX_cipher(e) ((e)->cipher) | ||
| 435 | #define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid) | ||
| 436 | #define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size) | ||
| 437 | #define EVP_CIPHER_CTX_key_length(e) ((e)->cipher->key_len) | ||
| 438 | #define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len) | ||
| 439 | #define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) | ||
| 440 | #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d)) | ||
| 441 | #define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) | ||
| 442 | |||
| 443 | #define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) | ||
| 444 | #define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) | ||
| 445 | |||
| 446 | #define EVP_SignInit(a,b) EVP_DigestInit(a,b) | ||
| 447 | #define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) | ||
| 448 | #define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) | ||
| 449 | #define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) | ||
| 450 | #define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) | ||
| 451 | #define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) | ||
| 452 | |||
| 453 | #ifdef CONST_STRICT | ||
| 454 | void BIO_set_md(BIO *,const EVP_MD *md); | ||
| 455 | #else | ||
| 456 | # define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) | ||
| 457 | #endif | ||
| 458 | #define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) | ||
| 459 | #define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) | ||
| 460 | #define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) | ||
| 461 | #define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) | ||
| 462 | |||
| 463 | #define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l)) | ||
| 464 | |||
| 465 | #define EVP_add_cipher_alias(n,alias) \ | ||
| 466 | OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) | ||
| 467 | #define EVP_add_digest_alias(n,alias) \ | ||
| 468 | OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) | ||
| 469 | #define EVP_delete_cipher_alias(alias) \ | ||
| 470 | OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); | ||
| 471 | #define EVP_delete_digest_alias(alias) \ | ||
| 472 | OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); | ||
| 473 | |||
| 474 | |||
| 475 | int EVP_MD_CTX_copy(EVP_MD_CTX *out,EVP_MD_CTX *in); | ||
| 476 | void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); | ||
| 477 | void EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, | ||
| 478 | unsigned int cnt); | ||
| 479 | void EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); | ||
| 480 | |||
| 481 | int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); | ||
| 482 | void EVP_set_pw_prompt(char *prompt); | ||
| 483 | char * EVP_get_pw_prompt(void); | ||
| 484 | |||
| 485 | int EVP_BytesToKey(const EVP_CIPHER *type,EVP_MD *md,unsigned char *salt, | ||
| 486 | unsigned char *data, int datal, int count, | ||
| 487 | unsigned char *key,unsigned char *iv); | ||
| 488 | |||
| 489 | void EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, | ||
| 490 | unsigned char *key, unsigned char *iv); | ||
| 491 | void EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 492 | int *outl, unsigned char *in, int inl); | ||
| 493 | void EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); | ||
| 494 | |||
| 495 | void EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, | ||
| 496 | unsigned char *key, unsigned char *iv); | ||
| 497 | void EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 498 | int *outl, unsigned char *in, int inl); | ||
| 499 | int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); | ||
| 500 | |||
| 501 | void EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type, | ||
| 502 | unsigned char *key,unsigned char *iv,int enc); | ||
| 503 | void EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, | ||
| 504 | int *outl, unsigned char *in, int inl); | ||
| 505 | int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); | ||
| 506 | |||
| 507 | int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, | ||
| 508 | EVP_PKEY *pkey); | ||
| 509 | |||
| 510 | int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, | ||
| 511 | unsigned int siglen,EVP_PKEY *pkey); | ||
| 512 | |||
| 513 | int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek, | ||
| 514 | int ekl,unsigned char *iv,EVP_PKEY *priv); | ||
| 515 | int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); | ||
| 516 | |||
| 517 | int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, | ||
| 518 | int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk); | ||
| 519 | void EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); | ||
| 520 | |||
| 521 | void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); | ||
| 522 | void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out, | ||
| 523 | int *outl,unsigned char *in,int inl); | ||
| 524 | void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); | ||
| 525 | int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); | ||
| 526 | |||
| 527 | void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); | ||
| 528 | int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, | ||
| 529 | unsigned char *in, int inl); | ||
| 530 | int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned | ||
| 531 | char *out, int *outl); | ||
| 532 | int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); | ||
| 533 | |||
| 534 | void ERR_load_EVP_strings(void ); | ||
| 535 | |||
| 536 | void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); | ||
| 537 | void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); | ||
| 538 | |||
| 539 | #ifdef HEADER_BIO_H | ||
| 540 | BIO_METHOD *BIO_f_md(void); | ||
| 541 | BIO_METHOD *BIO_f_base64(void); | ||
| 542 | BIO_METHOD *BIO_f_cipher(void); | ||
| 543 | BIO_METHOD *BIO_f_reliable(void); | ||
| 544 | void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,unsigned char *k, | ||
| 545 | unsigned char *i, int enc); | ||
| 546 | #endif | ||
| 547 | |||
| 548 | EVP_MD *EVP_md_null(void); | ||
| 549 | EVP_MD *EVP_md2(void); | ||
| 550 | EVP_MD *EVP_md5(void); | ||
| 551 | EVP_MD *EVP_sha(void); | ||
| 552 | EVP_MD *EVP_sha1(void); | ||
| 553 | EVP_MD *EVP_dss(void); | ||
| 554 | EVP_MD *EVP_dss1(void); | ||
| 555 | EVP_MD *EVP_mdc2(void); | ||
| 556 | EVP_MD *EVP_ripemd160(void); | ||
| 557 | |||
| 558 | EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ | ||
| 559 | EVP_CIPHER *EVP_des_ecb(void); | ||
| 560 | EVP_CIPHER *EVP_des_ede(void); | ||
| 561 | EVP_CIPHER *EVP_des_ede3(void); | ||
| 562 | EVP_CIPHER *EVP_des_cfb(void); | ||
| 563 | EVP_CIPHER *EVP_des_ede_cfb(void); | ||
| 564 | EVP_CIPHER *EVP_des_ede3_cfb(void); | ||
| 565 | EVP_CIPHER *EVP_des_ofb(void); | ||
| 566 | EVP_CIPHER *EVP_des_ede_ofb(void); | ||
| 567 | EVP_CIPHER *EVP_des_ede3_ofb(void); | ||
| 568 | EVP_CIPHER *EVP_des_cbc(void); | ||
| 569 | EVP_CIPHER *EVP_des_ede_cbc(void); | ||
| 570 | EVP_CIPHER *EVP_des_ede3_cbc(void); | ||
| 571 | EVP_CIPHER *EVP_desx_cbc(void); | ||
| 572 | EVP_CIPHER *EVP_rc4(void); | ||
| 573 | EVP_CIPHER *EVP_rc4_40(void); | ||
| 574 | EVP_CIPHER *EVP_idea_ecb(void); | ||
| 575 | EVP_CIPHER *EVP_idea_cfb(void); | ||
| 576 | EVP_CIPHER *EVP_idea_ofb(void); | ||
| 577 | EVP_CIPHER *EVP_idea_cbc(void); | ||
| 578 | EVP_CIPHER *EVP_rc2_ecb(void); | ||
| 579 | EVP_CIPHER *EVP_rc2_cbc(void); | ||
| 580 | EVP_CIPHER *EVP_rc2_40_cbc(void); | ||
| 581 | EVP_CIPHER *EVP_rc2_64_cbc(void); | ||
| 582 | EVP_CIPHER *EVP_rc2_cfb(void); | ||
| 583 | EVP_CIPHER *EVP_rc2_ofb(void); | ||
| 584 | EVP_CIPHER *EVP_bf_ecb(void); | ||
| 585 | EVP_CIPHER *EVP_bf_cbc(void); | ||
| 586 | EVP_CIPHER *EVP_bf_cfb(void); | ||
| 587 | EVP_CIPHER *EVP_bf_ofb(void); | ||
| 588 | EVP_CIPHER *EVP_cast5_ecb(void); | ||
| 589 | EVP_CIPHER *EVP_cast5_cbc(void); | ||
| 590 | EVP_CIPHER *EVP_cast5_cfb(void); | ||
| 591 | EVP_CIPHER *EVP_cast5_ofb(void); | ||
| 592 | EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); | ||
| 593 | EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); | ||
| 594 | EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); | ||
| 595 | EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); | ||
| 596 | |||
| 597 | void OpenSSL_add_all_algorithms(void); | ||
| 598 | void OpenSSL_add_all_ciphers(void); | ||
| 599 | void OpenSSL_add_all_digests(void); | ||
| 600 | #define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms() | ||
| 601 | #define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers() | ||
| 602 | #define SSLeay_add_all_digests() OpenSSL_add_all_digests() | ||
| 603 | |||
| 604 | int EVP_add_cipher(EVP_CIPHER *cipher); | ||
| 605 | int EVP_add_digest(EVP_MD *digest); | ||
| 606 | |||
| 607 | const EVP_CIPHER *EVP_get_cipherbyname(const char *name); | ||
| 608 | const EVP_MD *EVP_get_digestbyname(const char *name); | ||
| 609 | void EVP_cleanup(void); | ||
| 610 | |||
| 611 | int EVP_PKEY_decrypt(unsigned char *dec_key,unsigned char *enc_key, | ||
| 612 | int enc_key_len,EVP_PKEY *private_key); | ||
| 613 | int EVP_PKEY_encrypt(unsigned char *enc_key, | ||
| 614 | unsigned char *key,int key_len,EVP_PKEY *pub_key); | ||
| 615 | int EVP_PKEY_type(int type); | ||
| 616 | int EVP_PKEY_bits(EVP_PKEY *pkey); | ||
| 617 | int EVP_PKEY_size(EVP_PKEY *pkey); | ||
| 618 | int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); | ||
| 619 | #ifndef NO_RSA | ||
| 620 | int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,RSA *key); | ||
| 621 | RSA * EVP_PKEY_get1_RSA(EVP_PKEY *pkey); | ||
| 622 | #endif | ||
| 623 | #ifndef NO_DSA | ||
| 624 | int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,DSA *key); | ||
| 625 | DSA * EVP_PKEY_get1_DSA(EVP_PKEY *pkey); | ||
| 626 | #endif | ||
| 627 | #ifndef NO_DH | ||
| 628 | int EVP_PKEY_set1_DH(EVP_PKEY *pkey,DH *key); | ||
| 629 | DH * EVP_PKEY_get1_DH(EVP_PKEY *pkey); | ||
| 630 | #endif | ||
| 631 | EVP_PKEY * EVP_PKEY_new(void); | ||
| 632 | void EVP_PKEY_free(EVP_PKEY *pkey); | ||
| 633 | EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp, | ||
| 634 | long length); | ||
| 635 | int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); | ||
| 636 | |||
| 637 | EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp, | ||
| 638 | long length); | ||
| 639 | EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp, | ||
| 640 | long length); | ||
| 641 | int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); | ||
| 642 | |||
| 643 | int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from); | ||
| 644 | int EVP_PKEY_missing_parameters(EVP_PKEY *pkey); | ||
| 645 | int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); | ||
| 646 | int EVP_PKEY_cmp_parameters(EVP_PKEY *a,EVP_PKEY *b); | ||
| 647 | |||
| 648 | int EVP_CIPHER_type(const EVP_CIPHER *ctx); | ||
| 649 | |||
| 650 | /* calls methods */ | ||
| 651 | int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); | ||
| 652 | int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); | ||
| 653 | |||
| 654 | /* These are used by EVP_CIPHER methods */ | ||
| 655 | int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); | ||
| 656 | int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); | ||
| 657 | |||
| 658 | /* PKCS5 password based encryption */ | ||
| 659 | int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | ||
| 660 | ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md, | ||
| 661 | int en_de); | ||
| 662 | int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, | ||
| 663 | unsigned char *salt, int saltlen, int iter, | ||
| 664 | int keylen, unsigned char *out); | ||
| 665 | int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | ||
| 666 | ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md, | ||
| 667 | int en_de); | ||
| 668 | |||
| 669 | void PKCS5_PBE_add(void); | ||
| 670 | |||
| 671 | int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, | ||
| 672 | ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); | ||
| 673 | int EVP_PBE_alg_add(int nid, EVP_CIPHER *cipher, EVP_MD *md, | ||
| 674 | EVP_PBE_KEYGEN *keygen); | ||
| 675 | void EVP_PBE_cleanup(void); | ||
| 676 | |||
| 677 | /* BEGIN ERROR CODES */ | ||
| 678 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 679 | * made after this point may be overwritten when the script is next run. | ||
| 680 | */ | ||
| 681 | |||
| 682 | /* Error codes for the EVP functions. */ | ||
| 683 | |||
| 684 | /* Function codes. */ | ||
| 685 | #define EVP_F_D2I_PKEY 100 | ||
| 686 | #define EVP_F_EVP_DECRYPTFINAL 101 | ||
| 687 | #define EVP_F_EVP_MD_CTX_COPY 110 | ||
| 688 | #define EVP_F_EVP_OPENINIT 102 | ||
| 689 | #define EVP_F_EVP_PBE_ALG_ADD 115 | ||
| 690 | #define EVP_F_EVP_PBE_CIPHERINIT 116 | ||
| 691 | #define EVP_F_EVP_PKCS82PKEY 111 | ||
| 692 | #define EVP_F_EVP_PKCS8_SET_BROKEN 112 | ||
| 693 | #define EVP_F_EVP_PKEY2PKCS8 113 | ||
| 694 | #define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 | ||
| 695 | #define EVP_F_EVP_PKEY_DECRYPT 104 | ||
| 696 | #define EVP_F_EVP_PKEY_ENCRYPT 105 | ||
| 697 | #define EVP_F_EVP_PKEY_GET1_DH 119 | ||
| 698 | #define EVP_F_EVP_PKEY_GET1_DSA 120 | ||
| 699 | #define EVP_F_EVP_PKEY_GET1_RSA 121 | ||
| 700 | #define EVP_F_EVP_PKEY_NEW 106 | ||
| 701 | #define EVP_F_EVP_SIGNFINAL 107 | ||
| 702 | #define EVP_F_EVP_VERIFYFINAL 108 | ||
| 703 | #define EVP_F_PKCS5_PBE_KEYIVGEN 117 | ||
| 704 | #define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 | ||
| 705 | #define EVP_F_RC2_MAGIC_TO_METH 109 | ||
| 706 | |||
| 707 | /* Reason codes. */ | ||
| 708 | #define EVP_R_BAD_DECRYPT 100 | ||
| 709 | #define EVP_R_BN_DECODE_ERROR 112 | ||
| 710 | #define EVP_R_BN_PUBKEY_ERROR 113 | ||
| 711 | #define EVP_R_CIPHER_PARAMETER_ERROR 122 | ||
| 712 | #define EVP_R_DECODE_ERROR 114 | ||
| 713 | #define EVP_R_DIFFERENT_KEY_TYPES 101 | ||
| 714 | #define EVP_R_ENCODE_ERROR 115 | ||
| 715 | #define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 | ||
| 716 | #define EVP_R_EXPECTING_AN_RSA_KEY 127 | ||
| 717 | #define EVP_R_EXPECTING_A_DH_KEY 128 | ||
| 718 | #define EVP_R_EXPECTING_A_DSA_KEY 129 | ||
| 719 | #define EVP_R_INPUT_NOT_INITIALIZED 111 | ||
| 720 | #define EVP_R_IV_TOO_LARGE 102 | ||
| 721 | #define EVP_R_KEYGEN_FAILURE 120 | ||
| 722 | #define EVP_R_MISSING_PARAMETERS 103 | ||
| 723 | #define EVP_R_NO_DSA_PARAMETERS 116 | ||
| 724 | #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 | ||
| 725 | #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 | ||
| 726 | #define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117 | ||
| 727 | #define EVP_R_PUBLIC_KEY_NOT_RSA 106 | ||
| 728 | #define EVP_R_UNKNOWN_PBE_ALGORITHM 121 | ||
| 729 | #define EVP_R_UNSUPPORTED_CIPHER 107 | ||
| 730 | #define EVP_R_UNSUPPORTED_KEYLENGTH 123 | ||
| 731 | #define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 | ||
| 732 | #define EVP_R_UNSUPPORTED_KEY_SIZE 108 | ||
| 733 | #define EVP_R_UNSUPPORTED_PRF 125 | ||
| 734 | #define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 | ||
| 735 | #define EVP_R_UNSUPPORTED_SALT_TYPE 126 | ||
| 736 | #define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 | ||
| 737 | #define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 | ||
| 738 | |||
| 739 | #ifdef __cplusplus | ||
| 740 | } | ||
| 741 | #endif | ||
| 742 | #endif | ||
| 743 | |||
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c deleted file mode 100644 index 5299a65b6a..0000000000 --- a/src/lib/libcrypto/evp/evp_enc.c +++ /dev/null | |||
| @@ -1,270 +0,0 @@ | |||
| 1 | /* crypto/evp/evp_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | |||
| 63 | const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT; | ||
| 64 | |||
| 65 | void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) | ||
| 66 | { | ||
| 67 | memset(ctx,0,sizeof(EVP_CIPHER_CTX)); | ||
| 68 | /* ctx->cipher=NULL; */ | ||
| 69 | } | ||
| 70 | |||
| 71 | void EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *data, | ||
| 72 | unsigned char *key, unsigned char *iv, int enc) | ||
| 73 | { | ||
| 74 | if (enc) | ||
| 75 | EVP_EncryptInit(ctx,data,key,iv); | ||
| 76 | else | ||
| 77 | EVP_DecryptInit(ctx,data,key,iv); | ||
| 78 | } | ||
| 79 | |||
| 80 | void EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | ||
| 81 | unsigned char *in, int inl) | ||
| 82 | { | ||
| 83 | if (ctx->encrypt) | ||
| 84 | EVP_EncryptUpdate(ctx,out,outl,in,inl); | ||
| 85 | else EVP_DecryptUpdate(ctx,out,outl,in,inl); | ||
| 86 | } | ||
| 87 | |||
| 88 | int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
| 89 | { | ||
| 90 | if (ctx->encrypt) | ||
| 91 | { | ||
| 92 | EVP_EncryptFinal(ctx,out,outl); | ||
| 93 | return(1); | ||
| 94 | } | ||
| 95 | else return(EVP_DecryptFinal(ctx,out,outl)); | ||
| 96 | } | ||
| 97 | |||
| 98 | void EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | ||
| 99 | unsigned char *key, unsigned char *iv) | ||
| 100 | { | ||
| 101 | if (cipher != NULL) | ||
| 102 | ctx->cipher=cipher; | ||
| 103 | ctx->cipher->init(ctx,key,iv,1); | ||
| 104 | ctx->encrypt=1; | ||
| 105 | ctx->buf_len=0; | ||
| 106 | } | ||
| 107 | |||
| 108 | void EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, | ||
| 109 | unsigned char *key, unsigned char *iv) | ||
| 110 | { | ||
| 111 | if (cipher != NULL) | ||
| 112 | ctx->cipher=cipher; | ||
| 113 | ctx->cipher->init(ctx,key,iv,0); | ||
| 114 | ctx->encrypt=0; | ||
| 115 | ctx->buf_len=0; | ||
| 116 | } | ||
| 117 | |||
| 118 | |||
| 119 | void EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | ||
| 120 | unsigned char *in, int inl) | ||
| 121 | { | ||
| 122 | int i,j,bl; | ||
| 123 | |||
| 124 | i=ctx->buf_len; | ||
| 125 | bl=ctx->cipher->block_size; | ||
| 126 | *outl=0; | ||
| 127 | if ((inl == 0) && (i != bl)) return; | ||
| 128 | if (i != 0) | ||
| 129 | { | ||
| 130 | if (i+inl < bl) | ||
| 131 | { | ||
| 132 | memcpy(&(ctx->buf[i]),in,inl); | ||
| 133 | ctx->buf_len+=inl; | ||
| 134 | return; | ||
| 135 | } | ||
| 136 | else | ||
| 137 | { | ||
| 138 | j=bl-i; | ||
| 139 | if (j != 0) memcpy(&(ctx->buf[i]),in,j); | ||
| 140 | ctx->cipher->do_cipher(ctx,out,ctx->buf,bl); | ||
| 141 | inl-=j; | ||
| 142 | in+=j; | ||
| 143 | out+=bl; | ||
| 144 | *outl+=bl; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | i=inl%bl; /* how much is left */ | ||
| 148 | inl-=i; | ||
| 149 | if (inl > 0) | ||
| 150 | { | ||
| 151 | ctx->cipher->do_cipher(ctx,out,in,inl); | ||
| 152 | *outl+=inl; | ||
| 153 | } | ||
| 154 | |||
| 155 | if (i != 0) | ||
| 156 | memcpy(ctx->buf,&(in[inl]),i); | ||
| 157 | ctx->buf_len=i; | ||
| 158 | } | ||
| 159 | |||
| 160 | void EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
| 161 | { | ||
| 162 | int i,n,b,bl; | ||
| 163 | |||
| 164 | b=ctx->cipher->block_size; | ||
| 165 | if (b == 1) | ||
| 166 | { | ||
| 167 | *outl=0; | ||
| 168 | return; | ||
| 169 | } | ||
| 170 | bl=ctx->buf_len; | ||
| 171 | n=b-bl; | ||
| 172 | for (i=bl; i<b; i++) | ||
| 173 | ctx->buf[i]=n; | ||
| 174 | ctx->cipher->do_cipher(ctx,out,ctx->buf,b); | ||
| 175 | *outl=b; | ||
| 176 | } | ||
| 177 | |||
| 178 | void EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, | ||
| 179 | unsigned char *in, int inl) | ||
| 180 | { | ||
| 181 | int b,bl,n; | ||
| 182 | int keep_last=0; | ||
| 183 | |||
| 184 | *outl=0; | ||
| 185 | if (inl == 0) return; | ||
| 186 | |||
| 187 | b=ctx->cipher->block_size; | ||
| 188 | if (b > 1) | ||
| 189 | { | ||
| 190 | /* Is the input a multiple of the block size? */ | ||
| 191 | bl=ctx->buf_len; | ||
| 192 | n=inl+bl; | ||
| 193 | if (n%b == 0) | ||
| 194 | { | ||
| 195 | if (inl < b) /* must be 'just one' buff */ | ||
| 196 | { | ||
| 197 | memcpy(&(ctx->buf[bl]),in,inl); | ||
| 198 | ctx->buf_len=b; | ||
| 199 | *outl=0; | ||
| 200 | return; | ||
| 201 | } | ||
| 202 | keep_last=1; | ||
| 203 | inl-=b; /* don't do the last block */ | ||
| 204 | } | ||
| 205 | } | ||
| 206 | EVP_EncryptUpdate(ctx,out,outl,in,inl); | ||
| 207 | |||
| 208 | /* if we have 'decrypted' a multiple of block size, make sure | ||
| 209 | * we have a copy of this last block */ | ||
| 210 | if (keep_last) | ||
| 211 | { | ||
| 212 | memcpy(&(ctx->buf[0]),&(in[inl]),b); | ||
| 213 | #ifdef DEBUG | ||
| 214 | if (ctx->buf_len != 0) | ||
| 215 | { | ||
| 216 | abort(); | ||
| 217 | } | ||
| 218 | #endif | ||
| 219 | ctx->buf_len=b; | ||
| 220 | } | ||
| 221 | } | ||
| 222 | |||
| 223 | int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
| 224 | { | ||
| 225 | int i,b; | ||
| 226 | int n; | ||
| 227 | |||
| 228 | *outl=0; | ||
| 229 | b=ctx->cipher->block_size; | ||
| 230 | if (b > 1) | ||
| 231 | { | ||
| 232 | if (ctx->buf_len != b) | ||
| 233 | { | ||
| 234 | EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_WRONG_FINAL_BLOCK_LENGTH); | ||
| 235 | return(0); | ||
| 236 | } | ||
| 237 | EVP_EncryptUpdate(ctx,ctx->buf,&n,ctx->buf,0); | ||
| 238 | if (n != b) | ||
| 239 | return(0); | ||
| 240 | n=ctx->buf[b-1]; | ||
| 241 | if (n > b) | ||
| 242 | { | ||
| 243 | EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT); | ||
| 244 | return(0); | ||
| 245 | } | ||
| 246 | for (i=0; i<n; i++) | ||
| 247 | { | ||
| 248 | if (ctx->buf[--b] != n) | ||
| 249 | { | ||
| 250 | EVPerr(EVP_F_EVP_DECRYPTFINAL,EVP_R_BAD_DECRYPT); | ||
| 251 | return(0); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | n=ctx->cipher->block_size-n; | ||
| 255 | for (i=0; i<n; i++) | ||
| 256 | out[i]=ctx->buf[i]; | ||
| 257 | *outl=n; | ||
| 258 | } | ||
| 259 | else | ||
| 260 | *outl=0; | ||
| 261 | return(1); | ||
| 262 | } | ||
| 263 | |||
| 264 | void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) | ||
| 265 | { | ||
| 266 | if ((c->cipher != NULL) && (c->cipher->cleanup != NULL)) | ||
| 267 | c->cipher->cleanup(c); | ||
| 268 | memset(c,0,sizeof(EVP_CIPHER_CTX)); | ||
| 269 | } | ||
| 270 | |||
diff --git a/src/lib/libcrypto/evp/evp_err.c b/src/lib/libcrypto/evp/evp_err.c deleted file mode 100644 index fc149cbb1a..0000000000 --- a/src/lib/libcrypto/evp/evp_err.c +++ /dev/null | |||
| @@ -1,143 +0,0 @@ | |||
| 1 | /* crypto/evp/evp_err.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * openssl-core@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file, | ||
| 58 | * only reason strings will be preserved. | ||
| 59 | */ | ||
| 60 | |||
| 61 | #include <stdio.h> | ||
| 62 | #include <openssl/err.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | |||
| 65 | /* BEGIN ERROR CODES */ | ||
| 66 | #ifndef NO_ERR | ||
| 67 | static ERR_STRING_DATA EVP_str_functs[]= | ||
| 68 | { | ||
| 69 | {ERR_PACK(0,EVP_F_D2I_PKEY,0), "D2I_PKEY"}, | ||
| 70 | {ERR_PACK(0,EVP_F_EVP_DECRYPTFINAL,0), "EVP_DecryptFinal"}, | ||
| 71 | {ERR_PACK(0,EVP_F_EVP_MD_CTX_COPY,0), "EVP_MD_CTX_copy"}, | ||
| 72 | {ERR_PACK(0,EVP_F_EVP_OPENINIT,0), "EVP_OpenInit"}, | ||
| 73 | {ERR_PACK(0,EVP_F_EVP_PBE_ALG_ADD,0), "EVP_PBE_alg_add"}, | ||
| 74 | {ERR_PACK(0,EVP_F_EVP_PBE_CIPHERINIT,0), "EVP_PBE_CipherInit"}, | ||
| 75 | {ERR_PACK(0,EVP_F_EVP_PKCS82PKEY,0), "EVP_PKCS82PKEY"}, | ||
| 76 | {ERR_PACK(0,EVP_F_EVP_PKCS8_SET_BROKEN,0), "EVP_PKCS8_SET_BROKEN"}, | ||
| 77 | {ERR_PACK(0,EVP_F_EVP_PKEY2PKCS8,0), "EVP_PKEY2PKCS8"}, | ||
| 78 | {ERR_PACK(0,EVP_F_EVP_PKEY_COPY_PARAMETERS,0), "EVP_PKEY_copy_parameters"}, | ||
| 79 | {ERR_PACK(0,EVP_F_EVP_PKEY_DECRYPT,0), "EVP_PKEY_decrypt"}, | ||
| 80 | {ERR_PACK(0,EVP_F_EVP_PKEY_ENCRYPT,0), "EVP_PKEY_encrypt"}, | ||
| 81 | {ERR_PACK(0,EVP_F_EVP_PKEY_GET1_DH,0), "EVP_PKEY_get1_DH"}, | ||
| 82 | {ERR_PACK(0,EVP_F_EVP_PKEY_GET1_DSA,0), "EVP_PKEY_get1_DSA"}, | ||
| 83 | {ERR_PACK(0,EVP_F_EVP_PKEY_GET1_RSA,0), "EVP_PKEY_get1_RSA"}, | ||
| 84 | {ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"}, | ||
| 85 | {ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"}, | ||
| 86 | {ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"}, | ||
| 87 | {ERR_PACK(0,EVP_F_PKCS5_PBE_KEYIVGEN,0), "PKCS5_PBE_keyivgen"}, | ||
| 88 | {ERR_PACK(0,EVP_F_PKCS5_V2_PBE_KEYIVGEN,0), "PKCS5_v2_PBE_keyivgen"}, | ||
| 89 | {ERR_PACK(0,EVP_F_RC2_MAGIC_TO_METH,0), "RC2_MAGIC_TO_METH"}, | ||
| 90 | {0,NULL} | ||
| 91 | }; | ||
| 92 | |||
| 93 | static ERR_STRING_DATA EVP_str_reasons[]= | ||
| 94 | { | ||
| 95 | {EVP_R_BAD_DECRYPT ,"bad decrypt"}, | ||
| 96 | {EVP_R_BN_DECODE_ERROR ,"bn decode error"}, | ||
| 97 | {EVP_R_BN_PUBKEY_ERROR ,"bn pubkey error"}, | ||
| 98 | {EVP_R_CIPHER_PARAMETER_ERROR ,"cipher parameter error"}, | ||
| 99 | {EVP_R_DECODE_ERROR ,"decode error"}, | ||
| 100 | {EVP_R_DIFFERENT_KEY_TYPES ,"different key types"}, | ||
| 101 | {EVP_R_ENCODE_ERROR ,"encode error"}, | ||
| 102 | {EVP_R_EVP_PBE_CIPHERINIT_ERROR ,"evp pbe cipherinit error"}, | ||
| 103 | {EVP_R_EXPECTING_AN_RSA_KEY ,"expecting an rsa key"}, | ||
| 104 | {EVP_R_EXPECTING_A_DH_KEY ,"expecting a dh key"}, | ||
| 105 | {EVP_R_EXPECTING_A_DSA_KEY ,"expecting a dsa key"}, | ||
| 106 | {EVP_R_INPUT_NOT_INITIALIZED ,"input not initialized"}, | ||
| 107 | {EVP_R_IV_TOO_LARGE ,"iv too large"}, | ||
| 108 | {EVP_R_KEYGEN_FAILURE ,"keygen failure"}, | ||
| 109 | {EVP_R_MISSING_PARAMETERS ,"missing parameters"}, | ||
| 110 | {EVP_R_NO_DSA_PARAMETERS ,"no dsa parameters"}, | ||
| 111 | {EVP_R_NO_SIGN_FUNCTION_CONFIGURED ,"no sign function configured"}, | ||
| 112 | {EVP_R_NO_VERIFY_FUNCTION_CONFIGURED ,"no verify function configured"}, | ||
| 113 | {EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE ,"pkcs8 unknown broken type"}, | ||
| 114 | {EVP_R_PUBLIC_KEY_NOT_RSA ,"public key not rsa"}, | ||
| 115 | {EVP_R_UNKNOWN_PBE_ALGORITHM ,"unknown pbe algorithm"}, | ||
| 116 | {EVP_R_UNSUPPORTED_CIPHER ,"unsupported cipher"}, | ||
| 117 | {EVP_R_UNSUPPORTED_KEYLENGTH ,"unsupported keylength"}, | ||
| 118 | {EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION,"unsupported key derivation function"}, | ||
| 119 | {EVP_R_UNSUPPORTED_KEY_SIZE ,"unsupported key size"}, | ||
| 120 | {EVP_R_UNSUPPORTED_PRF ,"unsupported prf"}, | ||
| 121 | {EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM ,"unsupported private key algorithm"}, | ||
| 122 | {EVP_R_UNSUPPORTED_SALT_TYPE ,"unsupported salt type"}, | ||
| 123 | {EVP_R_WRONG_FINAL_BLOCK_LENGTH ,"wrong final block length"}, | ||
| 124 | {EVP_R_WRONG_PUBLIC_KEY_TYPE ,"wrong public key type"}, | ||
| 125 | {0,NULL} | ||
| 126 | }; | ||
| 127 | |||
| 128 | #endif | ||
| 129 | |||
| 130 | void ERR_load_EVP_strings(void) | ||
| 131 | { | ||
| 132 | static int init=1; | ||
| 133 | |||
| 134 | if (init) | ||
| 135 | { | ||
| 136 | init=0; | ||
| 137 | #ifndef NO_ERR | ||
| 138 | ERR_load_strings(ERR_LIB_EVP,EVP_str_functs); | ||
| 139 | ERR_load_strings(ERR_LIB_EVP,EVP_str_reasons); | ||
| 140 | #endif | ||
| 141 | |||
| 142 | } | ||
| 143 | } | ||
diff --git a/src/lib/libcrypto/evp/evp_key.c b/src/lib/libcrypto/evp/evp_key.c deleted file mode 100644 index 667c21cca8..0000000000 --- a/src/lib/libcrypto/evp/evp_key.c +++ /dev/null | |||
| @@ -1,159 +0,0 @@ | |||
| 1 | /* crypto/evp/evp_key.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/x509.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | |||
| 65 | /* should be init to zeros. */ | ||
| 66 | static char prompt_string[80]; | ||
| 67 | |||
| 68 | void EVP_set_pw_prompt(char *prompt) | ||
| 69 | { | ||
| 70 | if (prompt == NULL) | ||
| 71 | prompt_string[0]='\0'; | ||
| 72 | else | ||
| 73 | strncpy(prompt_string,prompt,79); | ||
| 74 | } | ||
| 75 | |||
| 76 | char *EVP_get_pw_prompt(void) | ||
| 77 | { | ||
| 78 | if (prompt_string[0] == '\0') | ||
| 79 | return(NULL); | ||
| 80 | else | ||
| 81 | return(prompt_string); | ||
| 82 | } | ||
| 83 | |||
| 84 | /* For historical reasons, the standard function for reading passwords is | ||
| 85 | * in the DES library -- if someone ever wants to disable DES, | ||
| 86 | * this function will fail */ | ||
| 87 | int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify) | ||
| 88 | { | ||
| 89 | #ifndef NO_DES | ||
| 90 | if ((prompt == NULL) && (prompt_string[0] != '\0')) | ||
| 91 | prompt=prompt_string; | ||
| 92 | return(des_read_pw_string(buf,len,prompt,verify)); | ||
| 93 | #else | ||
| 94 | return -1; | ||
| 95 | #endif | ||
| 96 | } | ||
| 97 | |||
| 98 | int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, unsigned char *salt, | ||
| 99 | unsigned char *data, int datal, int count, unsigned char *key, | ||
| 100 | unsigned char *iv) | ||
| 101 | { | ||
| 102 | EVP_MD_CTX c; | ||
| 103 | unsigned char md_buf[EVP_MAX_MD_SIZE]; | ||
| 104 | int niv,nkey,addmd=0; | ||
| 105 | unsigned int mds=0,i; | ||
| 106 | |||
| 107 | nkey=type->key_len; | ||
| 108 | niv=type->iv_len; | ||
| 109 | |||
| 110 | if (data == NULL) return(nkey); | ||
| 111 | |||
| 112 | for (;;) | ||
| 113 | { | ||
| 114 | EVP_DigestInit(&c,md); | ||
| 115 | if (addmd++) | ||
| 116 | EVP_DigestUpdate(&c,&(md_buf[0]),mds); | ||
| 117 | EVP_DigestUpdate(&c,data,datal); | ||
| 118 | if (salt != NULL) | ||
| 119 | EVP_DigestUpdate(&c,salt,8); | ||
| 120 | EVP_DigestFinal(&c,&(md_buf[0]),&mds); | ||
| 121 | |||
| 122 | for (i=1; i<(unsigned int)count; i++) | ||
| 123 | { | ||
| 124 | EVP_DigestInit(&c,md); | ||
| 125 | EVP_DigestUpdate(&c,&(md_buf[0]),mds); | ||
| 126 | EVP_DigestFinal(&c,&(md_buf[0]),&mds); | ||
| 127 | } | ||
| 128 | i=0; | ||
| 129 | if (nkey) | ||
| 130 | { | ||
| 131 | for (;;) | ||
| 132 | { | ||
| 133 | if (nkey == 0) break; | ||
| 134 | if (i == mds) break; | ||
| 135 | if (key != NULL) | ||
| 136 | *(key++)=md_buf[i]; | ||
| 137 | nkey--; | ||
| 138 | i++; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | if (niv && (i != mds)) | ||
| 142 | { | ||
| 143 | for (;;) | ||
| 144 | { | ||
| 145 | if (niv == 0) break; | ||
| 146 | if (i == mds) break; | ||
| 147 | if (iv != NULL) | ||
| 148 | *(iv++)=md_buf[i]; | ||
| 149 | niv--; | ||
| 150 | i++; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | if ((nkey == 0) && (niv == 0)) break; | ||
| 154 | } | ||
| 155 | memset(&c,0,sizeof(c)); | ||
| 156 | memset(&(md_buf[0]),0,EVP_MAX_MD_SIZE); | ||
| 157 | return(type->key_len); | ||
| 158 | } | ||
| 159 | |||
diff --git a/src/lib/libcrypto/evp/evp_lib.c b/src/lib/libcrypto/evp/evp_lib.c deleted file mode 100644 index a431945ef5..0000000000 --- a/src/lib/libcrypto/evp/evp_lib.c +++ /dev/null | |||
| @@ -1,142 +0,0 @@ | |||
| 1 | /* crypto/evp/evp_lib.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | |||
| 64 | int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
| 65 | { | ||
| 66 | int ret; | ||
| 67 | |||
| 68 | if (c->cipher->set_asn1_parameters != NULL) | ||
| 69 | ret=c->cipher->set_asn1_parameters(c,type); | ||
| 70 | else | ||
| 71 | ret=1; | ||
| 72 | return(ret); | ||
| 73 | } | ||
| 74 | |||
| 75 | int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
| 76 | { | ||
| 77 | int ret; | ||
| 78 | |||
| 79 | if (c->cipher->get_asn1_parameters != NULL) | ||
| 80 | ret=c->cipher->get_asn1_parameters(c,type); | ||
| 81 | else | ||
| 82 | ret=1; | ||
| 83 | return(ret); | ||
| 84 | } | ||
| 85 | |||
| 86 | int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
| 87 | { | ||
| 88 | int i=0,l; | ||
| 89 | |||
| 90 | if (type != NULL) | ||
| 91 | { | ||
| 92 | l=EVP_CIPHER_CTX_iv_length(c); | ||
| 93 | i=ASN1_TYPE_get_octetstring(type,c->oiv,l); | ||
| 94 | if (i != l) | ||
| 95 | return(-1); | ||
| 96 | else if (i > 0) | ||
| 97 | memcpy(c->iv,c->oiv,l); | ||
| 98 | } | ||
| 99 | return(i); | ||
| 100 | } | ||
| 101 | |||
| 102 | int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | ||
| 103 | { | ||
| 104 | int i=0,j; | ||
| 105 | |||
| 106 | if (type != NULL) | ||
| 107 | { | ||
| 108 | j=EVP_CIPHER_CTX_iv_length(c); | ||
| 109 | i=ASN1_TYPE_set_octetstring(type,c->oiv,j); | ||
| 110 | } | ||
| 111 | return(i); | ||
| 112 | } | ||
| 113 | |||
| 114 | /* Convert the various cipher NIDs and dummies to a proper OID NID */ | ||
| 115 | int EVP_CIPHER_type(const EVP_CIPHER *ctx) | ||
| 116 | { | ||
| 117 | int nid; | ||
| 118 | ASN1_OBJECT *otmp; | ||
| 119 | nid = EVP_CIPHER_nid(ctx); | ||
| 120 | |||
| 121 | switch(nid) { | ||
| 122 | |||
| 123 | case NID_rc2_cbc: | ||
| 124 | case NID_rc2_64_cbc: | ||
| 125 | case NID_rc2_40_cbc: | ||
| 126 | |||
| 127 | return NID_rc2_cbc; | ||
| 128 | |||
| 129 | case NID_rc4: | ||
| 130 | case NID_rc4_40: | ||
| 131 | |||
| 132 | return NID_rc4; | ||
| 133 | |||
| 134 | default: | ||
| 135 | /* Check it has an OID and it is valid */ | ||
| 136 | otmp = OBJ_nid2obj(nid); | ||
| 137 | if(!otmp || !otmp->data) nid = NID_undef; | ||
| 138 | ASN1_OBJECT_free(otmp); | ||
| 139 | return nid; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
diff --git a/src/lib/libcrypto/evp/evp_pbe.c b/src/lib/libcrypto/evp/evp_pbe.c deleted file mode 100644 index 353c3ad667..0000000000 --- a/src/lib/libcrypto/evp/evp_pbe.c +++ /dev/null | |||
| @@ -1,134 +0,0 @@ | |||
| 1 | /* evp_pbe.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <openssl/evp.h> | ||
| 61 | #include <openssl/x509.h> | ||
| 62 | #include "cryptlib.h" | ||
| 63 | |||
| 64 | /* Password based encryption (PBE) functions */ | ||
| 65 | |||
| 66 | static STACK *pbe_algs; | ||
| 67 | |||
| 68 | /* Setup a cipher context from a PBE algorithm */ | ||
| 69 | |||
| 70 | typedef struct { | ||
| 71 | int pbe_nid; | ||
| 72 | EVP_CIPHER *cipher; | ||
| 73 | EVP_MD *md; | ||
| 74 | EVP_PBE_KEYGEN *keygen; | ||
| 75 | } EVP_PBE_CTL; | ||
| 76 | |||
| 77 | int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen, | ||
| 78 | ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de) | ||
| 79 | { | ||
| 80 | |||
| 81 | EVP_PBE_CTL *pbetmp, pbelu; | ||
| 82 | int i; | ||
| 83 | pbelu.pbe_nid = OBJ_obj2nid(pbe_obj); | ||
| 84 | if (pbelu.pbe_nid != NID_undef) i = sk_find(pbe_algs, (char *)&pbelu); | ||
| 85 | else i = -1; | ||
| 86 | |||
| 87 | if (i == -1) { | ||
| 88 | char obj_tmp[80]; | ||
| 89 | EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_UNKNOWN_PBE_ALGORITHM); | ||
| 90 | if (!pbe_obj) strcpy (obj_tmp, "NULL"); | ||
| 91 | else i2t_ASN1_OBJECT(obj_tmp, 80, pbe_obj); | ||
| 92 | ERR_add_error_data(2, "TYPE=", obj_tmp); | ||
| 93 | return 0; | ||
| 94 | } | ||
| 95 | if (passlen == -1) passlen = strlen(pass); | ||
| 96 | pbetmp = (EVP_PBE_CTL *)sk_value (pbe_algs, i); | ||
| 97 | i = (*pbetmp->keygen)(ctx, pass, passlen, param, pbetmp->cipher, | ||
| 98 | pbetmp->md, en_de); | ||
| 99 | if (!i) { | ||
| 100 | EVPerr(EVP_F_EVP_PBE_CIPHERINIT,EVP_R_KEYGEN_FAILURE); | ||
| 101 | return 0; | ||
| 102 | } | ||
| 103 | return 1; | ||
| 104 | } | ||
| 105 | |||
| 106 | static int pbe_cmp (EVP_PBE_CTL **pbe1, EVP_PBE_CTL **pbe2) | ||
| 107 | { | ||
| 108 | return ((*pbe1)->pbe_nid - (*pbe2)->pbe_nid); | ||
| 109 | } | ||
| 110 | |||
| 111 | /* Add a PBE algorithm */ | ||
| 112 | |||
| 113 | int EVP_PBE_alg_add (int nid, EVP_CIPHER *cipher, EVP_MD *md, | ||
| 114 | EVP_PBE_KEYGEN *keygen) | ||
| 115 | { | ||
| 116 | EVP_PBE_CTL *pbe_tmp; | ||
| 117 | if (!pbe_algs) pbe_algs = sk_new (pbe_cmp); | ||
| 118 | if (!(pbe_tmp = (EVP_PBE_CTL*) Malloc (sizeof(EVP_PBE_CTL)))) { | ||
| 119 | EVPerr(EVP_F_EVP_PBE_ALG_ADD,ERR_R_MALLOC_FAILURE); | ||
| 120 | return 0; | ||
| 121 | } | ||
| 122 | pbe_tmp->pbe_nid = nid; | ||
| 123 | pbe_tmp->cipher = cipher; | ||
| 124 | pbe_tmp->md = md; | ||
| 125 | pbe_tmp->keygen = keygen; | ||
| 126 | sk_push (pbe_algs, (char *)pbe_tmp); | ||
| 127 | return 1; | ||
| 128 | } | ||
| 129 | |||
| 130 | void EVP_PBE_cleanup(void) | ||
| 131 | { | ||
| 132 | sk_pop_free(pbe_algs, FreeFunc); | ||
| 133 | pbe_algs = NULL; | ||
| 134 | } | ||
diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c deleted file mode 100644 index 4ab091fa56..0000000000 --- a/src/lib/libcrypto/evp/evp_pkey.c +++ /dev/null | |||
| @@ -1,407 +0,0 @@ | |||
| 1 | /* evp_pkey.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <stdlib.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/x509.h> | ||
| 63 | #include <openssl/rand.h> | ||
| 64 | |||
| 65 | static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8inf, EVP_PKEY *pkey); | ||
| 66 | |||
| 67 | /* Extract a private key from a PKCS8 structure */ | ||
| 68 | |||
| 69 | EVP_PKEY *EVP_PKCS82PKEY (PKCS8_PRIV_KEY_INFO *p8) | ||
| 70 | { | ||
| 71 | EVP_PKEY *pkey = NULL; | ||
| 72 | #ifndef NO_RSA | ||
| 73 | RSA *rsa = NULL; | ||
| 74 | #endif | ||
| 75 | #ifndef NO_DSA | ||
| 76 | DSA *dsa = NULL; | ||
| 77 | ASN1_INTEGER *privkey; | ||
| 78 | ASN1_TYPE *t1, *t2, *param = NULL; | ||
| 79 | STACK *ndsa = NULL; | ||
| 80 | BN_CTX *ctx = NULL; | ||
| 81 | int plen; | ||
| 82 | #endif | ||
| 83 | X509_ALGOR *a; | ||
| 84 | unsigned char *p; | ||
| 85 | int pkeylen; | ||
| 86 | char obj_tmp[80]; | ||
| 87 | |||
| 88 | if(p8->pkey->type == V_ASN1_OCTET_STRING) { | ||
| 89 | p8->broken = PKCS8_OK; | ||
| 90 | p = p8->pkey->value.octet_string->data; | ||
| 91 | pkeylen = p8->pkey->value.octet_string->length; | ||
| 92 | } else { | ||
| 93 | p8->broken = PKCS8_NO_OCTET; | ||
| 94 | p = p8->pkey->value.sequence->data; | ||
| 95 | pkeylen = p8->pkey->value.sequence->length; | ||
| 96 | } | ||
| 97 | if (!(pkey = EVP_PKEY_new())) { | ||
| 98 | EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); | ||
| 99 | return NULL; | ||
| 100 | } | ||
| 101 | a = p8->pkeyalg; | ||
| 102 | switch (OBJ_obj2nid(a->algorithm)) | ||
| 103 | { | ||
| 104 | #ifndef NO_RSA | ||
| 105 | case NID_rsaEncryption: | ||
| 106 | if (!(rsa = d2i_RSAPrivateKey (NULL, &p, pkeylen))) { | ||
| 107 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
| 108 | return NULL; | ||
| 109 | } | ||
| 110 | EVP_PKEY_assign_RSA (pkey, rsa); | ||
| 111 | break; | ||
| 112 | #endif | ||
| 113 | #ifndef NO_DSA | ||
| 114 | case NID_dsa: | ||
| 115 | /* PKCS#8 DSA is weird: you just get a private key integer | ||
| 116 | * and parameters in the AlgorithmIdentifier the pubkey must | ||
| 117 | * be recalculated. | ||
| 118 | */ | ||
| 119 | |||
| 120 | /* Check for broken DSA PKCS#8, UGH! */ | ||
| 121 | if(*p == (V_ASN1_SEQUENCE|V_ASN1_CONSTRUCTED)) { | ||
| 122 | if(!(ndsa = ASN1_seq_unpack(p, pkeylen, | ||
| 123 | (char *(*)())d2i_ASN1_TYPE, | ||
| 124 | ASN1_TYPE_free))) { | ||
| 125 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
| 126 | goto dsaerr; | ||
| 127 | } | ||
| 128 | if(sk_num(ndsa) != 2 ) { | ||
| 129 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
| 130 | goto dsaerr; | ||
| 131 | } | ||
| 132 | /* Handle Two broken types: | ||
| 133 | * SEQUENCE {parameters, priv_key} | ||
| 134 | * SEQUENCE {pub_key, priv_key} | ||
| 135 | */ | ||
| 136 | |||
| 137 | t1 = (ASN1_TYPE *)sk_value(ndsa, 0); | ||
| 138 | t2 = (ASN1_TYPE *)sk_value(ndsa, 1); | ||
| 139 | if(t1->type == V_ASN1_SEQUENCE) { | ||
| 140 | p8->broken = PKCS8_EMBEDDED_PARAM; | ||
| 141 | param = t1; | ||
| 142 | } else if(a->parameter->type == V_ASN1_SEQUENCE) { | ||
| 143 | p8->broken = PKCS8_NS_DB; | ||
| 144 | param = a->parameter; | ||
| 145 | } else { | ||
| 146 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
| 147 | goto dsaerr; | ||
| 148 | } | ||
| 149 | |||
| 150 | if(t2->type != V_ASN1_INTEGER) { | ||
| 151 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
| 152 | goto dsaerr; | ||
| 153 | } | ||
| 154 | privkey = t2->value.integer; | ||
| 155 | } else { | ||
| 156 | if (!(privkey=d2i_ASN1_INTEGER (NULL, &p, pkeylen))) { | ||
| 157 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
| 158 | goto dsaerr; | ||
| 159 | } | ||
| 160 | param = p8->pkeyalg->parameter; | ||
| 161 | } | ||
| 162 | if (!param || (param->type != V_ASN1_SEQUENCE)) { | ||
| 163 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
| 164 | goto dsaerr; | ||
| 165 | } | ||
| 166 | p = param->value.sequence->data; | ||
| 167 | plen = param->value.sequence->length; | ||
| 168 | if (!(dsa = d2i_DSAparams (NULL, &p, plen))) { | ||
| 169 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_DECODE_ERROR); | ||
| 170 | goto dsaerr; | ||
| 171 | } | ||
| 172 | /* We have parameters now set private key */ | ||
| 173 | if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { | ||
| 174 | EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_DECODE_ERROR); | ||
| 175 | goto dsaerr; | ||
| 176 | } | ||
| 177 | /* Calculate public key (ouch!) */ | ||
| 178 | if (!(dsa->pub_key = BN_new())) { | ||
| 179 | EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); | ||
| 180 | goto dsaerr; | ||
| 181 | } | ||
| 182 | if (!(ctx = BN_CTX_new())) { | ||
| 183 | EVPerr(EVP_F_EVP_PKCS82PKEY,ERR_R_MALLOC_FAILURE); | ||
| 184 | goto dsaerr; | ||
| 185 | } | ||
| 186 | |||
| 187 | if (!BN_mod_exp(dsa->pub_key, dsa->g, | ||
| 188 | dsa->priv_key, dsa->p, ctx)) { | ||
| 189 | |||
| 190 | EVPerr(EVP_F_EVP_PKCS82PKEY,EVP_R_BN_PUBKEY_ERROR); | ||
| 191 | goto dsaerr; | ||
| 192 | } | ||
| 193 | |||
| 194 | EVP_PKEY_assign_DSA(pkey, dsa); | ||
| 195 | BN_CTX_free (ctx); | ||
| 196 | if(ndsa) sk_pop_free(ndsa, ASN1_TYPE_free); | ||
| 197 | else ASN1_INTEGER_free(privkey); | ||
| 198 | break; | ||
| 199 | dsaerr: | ||
| 200 | BN_CTX_free (ctx); | ||
| 201 | sk_pop_free(ndsa, ASN1_TYPE_free); | ||
| 202 | DSA_free(dsa); | ||
| 203 | EVP_PKEY_free(pkey); | ||
| 204 | return NULL; | ||
| 205 | break; | ||
| 206 | #endif | ||
| 207 | default: | ||
| 208 | EVPerr(EVP_F_EVP_PKCS82PKEY, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); | ||
| 209 | if (!a->algorithm) strcpy (obj_tmp, "NULL"); | ||
| 210 | else i2t_ASN1_OBJECT(obj_tmp, 80, a->algorithm); | ||
| 211 | ERR_add_error_data(2, "TYPE=", obj_tmp); | ||
| 212 | EVP_PKEY_free (pkey); | ||
| 213 | return NULL; | ||
| 214 | } | ||
| 215 | return pkey; | ||
| 216 | } | ||
| 217 | |||
| 218 | PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey) | ||
| 219 | { | ||
| 220 | return EVP_PKEY2PKCS8_broken(pkey, PKCS8_OK); | ||
| 221 | } | ||
| 222 | |||
| 223 | /* Turn a private key into a PKCS8 structure */ | ||
| 224 | |||
| 225 | PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8_broken(EVP_PKEY *pkey, int broken) | ||
| 226 | { | ||
| 227 | PKCS8_PRIV_KEY_INFO *p8; | ||
| 228 | |||
| 229 | if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) { | ||
| 230 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
| 231 | return NULL; | ||
| 232 | } | ||
| 233 | p8->broken = broken; | ||
| 234 | ASN1_INTEGER_set (p8->version, 0); | ||
| 235 | if (!(p8->pkeyalg->parameter = ASN1_TYPE_new ())) { | ||
| 236 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
| 237 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
| 238 | return NULL; | ||
| 239 | } | ||
| 240 | p8->pkey->type = V_ASN1_OCTET_STRING; | ||
| 241 | switch (EVP_PKEY_type(pkey->type)) { | ||
| 242 | #ifndef NO_RSA | ||
| 243 | case EVP_PKEY_RSA: | ||
| 244 | |||
| 245 | if(p8->broken == PKCS8_NO_OCTET) p8->pkey->type = V_ASN1_SEQUENCE; | ||
| 246 | |||
| 247 | p8->pkeyalg->algorithm = OBJ_nid2obj(NID_rsaEncryption); | ||
| 248 | p8->pkeyalg->parameter->type = V_ASN1_NULL; | ||
| 249 | if (!ASN1_pack_string ((char *)pkey, i2d_PrivateKey, | ||
| 250 | &p8->pkey->value.octet_string)) { | ||
| 251 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
| 252 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
| 253 | return NULL; | ||
| 254 | } | ||
| 255 | break; | ||
| 256 | #endif | ||
| 257 | #ifndef NO_DSA | ||
| 258 | case EVP_PKEY_DSA: | ||
| 259 | if(!dsa_pkey2pkcs8(p8, pkey)) { | ||
| 260 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
| 261 | return NULL; | ||
| 262 | } | ||
| 263 | |||
| 264 | break; | ||
| 265 | #endif | ||
| 266 | default: | ||
| 267 | EVPerr(EVP_F_EVP_PKEY2PKCS8, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); | ||
| 268 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
| 269 | return NULL; | ||
| 270 | } | ||
| 271 | RAND_add(p8->pkey->value.octet_string->data, | ||
| 272 | p8->pkey->value.octet_string->length, 0); | ||
| 273 | return p8; | ||
| 274 | } | ||
| 275 | |||
| 276 | PKCS8_PRIV_KEY_INFO *PKCS8_set_broken(PKCS8_PRIV_KEY_INFO *p8, int broken) | ||
| 277 | { | ||
| 278 | switch (broken) { | ||
| 279 | |||
| 280 | case PKCS8_OK: | ||
| 281 | p8->broken = PKCS8_OK; | ||
| 282 | return p8; | ||
| 283 | break; | ||
| 284 | |||
| 285 | case PKCS8_NO_OCTET: | ||
| 286 | p8->broken = PKCS8_NO_OCTET; | ||
| 287 | p8->pkey->type = V_ASN1_SEQUENCE; | ||
| 288 | return p8; | ||
| 289 | break; | ||
| 290 | |||
| 291 | default: | ||
| 292 | EVPerr(EVP_F_EVP_PKCS8_SET_BROKEN,EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE); | ||
| 293 | return NULL; | ||
| 294 | break; | ||
| 295 | |||
| 296 | } | ||
| 297 | } | ||
| 298 | |||
| 299 | #ifndef NO_DSA | ||
| 300 | static int dsa_pkey2pkcs8(PKCS8_PRIV_KEY_INFO *p8, EVP_PKEY *pkey) | ||
| 301 | { | ||
| 302 | ASN1_STRING *params; | ||
| 303 | ASN1_INTEGER *prkey; | ||
| 304 | ASN1_TYPE *ttmp; | ||
| 305 | STACK *ndsa; | ||
| 306 | unsigned char *p, *q; | ||
| 307 | int len; | ||
| 308 | p8->pkeyalg->algorithm = OBJ_nid2obj(NID_dsa); | ||
| 309 | len = i2d_DSAparams (pkey->pkey.dsa, NULL); | ||
| 310 | if (!(p = Malloc(len))) { | ||
| 311 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
| 312 | PKCS8_PRIV_KEY_INFO_free (p8); | ||
| 313 | return 0; | ||
| 314 | } | ||
| 315 | q = p; | ||
| 316 | i2d_DSAparams (pkey->pkey.dsa, &q); | ||
| 317 | params = ASN1_STRING_new(); | ||
| 318 | ASN1_STRING_set(params, p, len); | ||
| 319 | Free(p); | ||
| 320 | /* Get private key into integer */ | ||
| 321 | if (!(prkey = BN_to_ASN1_INTEGER (pkey->pkey.dsa->priv_key, NULL))) { | ||
| 322 | EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR); | ||
| 323 | return 0; | ||
| 324 | } | ||
| 325 | |||
| 326 | switch(p8->broken) { | ||
| 327 | |||
| 328 | case PKCS8_OK: | ||
| 329 | case PKCS8_NO_OCTET: | ||
| 330 | |||
| 331 | if (!ASN1_pack_string((char *)prkey, i2d_ASN1_INTEGER, | ||
| 332 | &p8->pkey->value.octet_string)) { | ||
| 333 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
| 334 | M_ASN1_INTEGER_free (prkey); | ||
| 335 | return 0; | ||
| 336 | } | ||
| 337 | |||
| 338 | M_ASN1_INTEGER_free (prkey); | ||
| 339 | p8->pkeyalg->parameter->value.sequence = params; | ||
| 340 | p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE; | ||
| 341 | |||
| 342 | break; | ||
| 343 | |||
| 344 | case PKCS8_NS_DB: | ||
| 345 | |||
| 346 | p8->pkeyalg->parameter->value.sequence = params; | ||
| 347 | p8->pkeyalg->parameter->type = V_ASN1_SEQUENCE; | ||
| 348 | ndsa = sk_new_null(); | ||
| 349 | ttmp = ASN1_TYPE_new(); | ||
| 350 | if (!(ttmp->value.integer = BN_to_ASN1_INTEGER (pkey->pkey.dsa->pub_key, NULL))) { | ||
| 351 | EVPerr(EVP_F_EVP_PKEY2PKCS8,EVP_R_ENCODE_ERROR); | ||
| 352 | PKCS8_PRIV_KEY_INFO_free(p8); | ||
| 353 | return 0; | ||
| 354 | } | ||
| 355 | ttmp->type = V_ASN1_INTEGER; | ||
| 356 | sk_push(ndsa, (char *)ttmp); | ||
| 357 | |||
| 358 | ttmp = ASN1_TYPE_new(); | ||
| 359 | ttmp->value.integer = prkey; | ||
| 360 | ttmp->type = V_ASN1_INTEGER; | ||
| 361 | sk_push(ndsa, (char *)ttmp); | ||
| 362 | |||
| 363 | p8->pkey->value.octet_string = ASN1_OCTET_STRING_new(); | ||
| 364 | |||
| 365 | if (!ASN1_seq_pack(ndsa, i2d_ASN1_TYPE, | ||
| 366 | &p8->pkey->value.octet_string->data, | ||
| 367 | &p8->pkey->value.octet_string->length)) { | ||
| 368 | |||
| 369 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
| 370 | sk_pop_free(ndsa, ASN1_TYPE_free); | ||
| 371 | M_ASN1_INTEGER_free(prkey); | ||
| 372 | return 0; | ||
| 373 | } | ||
| 374 | sk_pop_free(ndsa, ASN1_TYPE_free); | ||
| 375 | break; | ||
| 376 | |||
| 377 | case PKCS8_EMBEDDED_PARAM: | ||
| 378 | |||
| 379 | p8->pkeyalg->parameter->type = V_ASN1_NULL; | ||
| 380 | ndsa = sk_new_null(); | ||
| 381 | ttmp = ASN1_TYPE_new(); | ||
| 382 | ttmp->value.sequence = params; | ||
| 383 | ttmp->type = V_ASN1_SEQUENCE; | ||
| 384 | sk_push(ndsa, (char *)ttmp); | ||
| 385 | |||
| 386 | ttmp = ASN1_TYPE_new(); | ||
| 387 | ttmp->value.integer = prkey; | ||
| 388 | ttmp->type = V_ASN1_INTEGER; | ||
| 389 | sk_push(ndsa, (char *)ttmp); | ||
| 390 | |||
| 391 | p8->pkey->value.octet_string = ASN1_OCTET_STRING_new(); | ||
| 392 | |||
| 393 | if (!ASN1_seq_pack(ndsa, i2d_ASN1_TYPE, | ||
| 394 | &p8->pkey->value.octet_string->data, | ||
| 395 | &p8->pkey->value.octet_string->length)) { | ||
| 396 | |||
| 397 | EVPerr(EVP_F_EVP_PKEY2PKCS8,ERR_R_MALLOC_FAILURE); | ||
| 398 | sk_pop_free(ndsa, ASN1_TYPE_free); | ||
| 399 | M_ASN1_INTEGER_free (prkey); | ||
| 400 | return 0; | ||
| 401 | } | ||
| 402 | sk_pop_free(ndsa, ASN1_TYPE_free); | ||
| 403 | break; | ||
| 404 | } | ||
| 405 | return 1; | ||
| 406 | } | ||
| 407 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_dss.c b/src/lib/libcrypto/evp/m_dss.c deleted file mode 100644 index 8ea826868e..0000000000 --- a/src/lib/libcrypto/evp/m_dss.c +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 1 | /* crypto/evp/m_dss.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/x509.h> | ||
| 64 | |||
| 65 | #ifndef NO_SHA | ||
| 66 | static EVP_MD dsa_md= | ||
| 67 | { | ||
| 68 | NID_dsaWithSHA, | ||
| 69 | NID_dsaWithSHA, | ||
| 70 | SHA_DIGEST_LENGTH, | ||
| 71 | SHA1_Init, | ||
| 72 | SHA1_Update, | ||
| 73 | SHA1_Final, | ||
| 74 | EVP_PKEY_DSA_method, | ||
| 75 | SHA_CBLOCK, | ||
| 76 | sizeof(EVP_MD *)+sizeof(SHA_CTX), | ||
| 77 | }; | ||
| 78 | |||
| 79 | EVP_MD *EVP_dss(void) | ||
| 80 | { | ||
| 81 | return(&dsa_md); | ||
| 82 | } | ||
| 83 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_dss1.c b/src/lib/libcrypto/evp/m_dss1.c deleted file mode 100644 index 9d8d1ce23e..0000000000 --- a/src/lib/libcrypto/evp/m_dss1.c +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 1 | /* crypto/evp/m_dss1.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_SHA | ||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | #include <openssl/objects.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | |||
| 66 | static EVP_MD dss1_md= | ||
| 67 | { | ||
| 68 | NID_dsa, | ||
| 69 | NID_dsaWithSHA1, | ||
| 70 | SHA_DIGEST_LENGTH, | ||
| 71 | SHA1_Init, | ||
| 72 | SHA1_Update, | ||
| 73 | SHA1_Final, | ||
| 74 | EVP_PKEY_DSA_method, | ||
| 75 | SHA_CBLOCK, | ||
| 76 | sizeof(EVP_MD *)+sizeof(SHA_CTX), | ||
| 77 | }; | ||
| 78 | |||
| 79 | EVP_MD *EVP_dss1(void) | ||
| 80 | { | ||
| 81 | return(&dss1_md); | ||
| 82 | } | ||
| 83 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_md5.c b/src/lib/libcrypto/evp/m_md5.c deleted file mode 100644 index 9fc9530127..0000000000 --- a/src/lib/libcrypto/evp/m_md5.c +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 1 | /* crypto/evp/m_md5.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_MD5 | ||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | #include <openssl/objects.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | |||
| 66 | static EVP_MD md5_md= | ||
| 67 | { | ||
| 68 | NID_md5, | ||
| 69 | NID_md5WithRSAEncryption, | ||
| 70 | MD5_DIGEST_LENGTH, | ||
| 71 | MD5_Init, | ||
| 72 | MD5_Update, | ||
| 73 | MD5_Final, | ||
| 74 | EVP_PKEY_RSA_method, | ||
| 75 | MD5_CBLOCK, | ||
| 76 | sizeof(EVP_MD *)+sizeof(MD5_CTX), | ||
| 77 | }; | ||
| 78 | |||
| 79 | EVP_MD *EVP_md5(void) | ||
| 80 | { | ||
| 81 | return(&md5_md); | ||
| 82 | } | ||
| 83 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_null.c b/src/lib/libcrypto/evp/m_null.c deleted file mode 100644 index e2dadf3dab..0000000000 --- a/src/lib/libcrypto/evp/m_null.c +++ /dev/null | |||
| @@ -1,88 +0,0 @@ | |||
| 1 | /* crypto/evp/m_null.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/x509.h> | ||
| 64 | |||
| 65 | static void function(void) | ||
| 66 | { | ||
| 67 | } | ||
| 68 | |||
| 69 | static EVP_MD null_md= | ||
| 70 | { | ||
| 71 | NID_undef, | ||
| 72 | NID_undef, | ||
| 73 | 0, | ||
| 74 | function, | ||
| 75 | function, | ||
| 76 | function, | ||
| 77 | |||
| 78 | EVP_PKEY_NULL_method, | ||
| 79 | 0, | ||
| 80 | sizeof(EVP_MD *), | ||
| 81 | }; | ||
| 82 | |||
| 83 | EVP_MD *EVP_md_null(void) | ||
| 84 | { | ||
| 85 | return(&null_md); | ||
| 86 | } | ||
| 87 | |||
| 88 | |||
diff --git a/src/lib/libcrypto/evp/m_ripemd.c b/src/lib/libcrypto/evp/m_ripemd.c deleted file mode 100644 index 3d781a4e8d..0000000000 --- a/src/lib/libcrypto/evp/m_ripemd.c +++ /dev/null | |||
| @@ -1,84 +0,0 @@ | |||
| 1 | /* crypto/evp/m_ripemd.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RIPEMD | ||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/ripemd.h> | ||
| 63 | #include <openssl/evp.h> | ||
| 64 | #include <openssl/objects.h> | ||
| 65 | #include <openssl/x509.h> | ||
| 66 | |||
| 67 | static EVP_MD ripemd160_md= | ||
| 68 | { | ||
| 69 | NID_ripemd160, | ||
| 70 | NID_ripemd160WithRSA, | ||
| 71 | RIPEMD160_DIGEST_LENGTH, | ||
| 72 | RIPEMD160_Init, | ||
| 73 | RIPEMD160_Update, | ||
| 74 | RIPEMD160_Final, | ||
| 75 | EVP_PKEY_RSA_method, | ||
| 76 | RIPEMD160_CBLOCK, | ||
| 77 | sizeof(EVP_MD *)+sizeof(RIPEMD160_CTX), | ||
| 78 | }; | ||
| 79 | |||
| 80 | EVP_MD *EVP_ripemd160(void) | ||
| 81 | { | ||
| 82 | return(&ripemd160_md); | ||
| 83 | } | ||
| 84 | #endif | ||
diff --git a/src/lib/libcrypto/evp/m_sha1.c b/src/lib/libcrypto/evp/m_sha1.c deleted file mode 100644 index 57a1ab0cce..0000000000 --- a/src/lib/libcrypto/evp/m_sha1.c +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 1 | /* crypto/evp/m_sha1.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_SHA | ||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | #include <openssl/objects.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | |||
| 66 | static EVP_MD sha1_md= | ||
| 67 | { | ||
| 68 | NID_sha1, | ||
| 69 | NID_sha1WithRSAEncryption, | ||
| 70 | SHA_DIGEST_LENGTH, | ||
| 71 | SHA1_Init, | ||
| 72 | SHA1_Update, | ||
| 73 | SHA1_Final, | ||
| 74 | EVP_PKEY_RSA_method, | ||
| 75 | SHA_CBLOCK, | ||
| 76 | sizeof(EVP_MD *)+sizeof(SHA_CTX), | ||
| 77 | }; | ||
| 78 | |||
| 79 | EVP_MD *EVP_sha1(void) | ||
| 80 | { | ||
| 81 | return(&sha1_md); | ||
| 82 | } | ||
| 83 | #endif | ||
diff --git a/src/lib/libcrypto/evp/names.c b/src/lib/libcrypto/evp/names.c deleted file mode 100644 index 620f43feaa..0000000000 --- a/src/lib/libcrypto/evp/names.c +++ /dev/null | |||
| @@ -1,123 +0,0 @@ | |||
| 1 | /* crypto/evp/names.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/x509.h> | ||
| 64 | |||
| 65 | int EVP_add_cipher(EVP_CIPHER *c) | ||
| 66 | { | ||
| 67 | int r; | ||
| 68 | |||
| 69 | r=OBJ_NAME_add(OBJ_nid2sn(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(char *)c); | ||
| 70 | if (r == 0) return(0); | ||
| 71 | r=OBJ_NAME_add(OBJ_nid2ln(c->nid),OBJ_NAME_TYPE_CIPHER_METH,(char *)c); | ||
| 72 | return(r); | ||
| 73 | } | ||
| 74 | |||
| 75 | int EVP_add_digest(EVP_MD *md) | ||
| 76 | { | ||
| 77 | int r; | ||
| 78 | const char *name; | ||
| 79 | |||
| 80 | name=OBJ_nid2sn(md->type); | ||
| 81 | r=OBJ_NAME_add(name,OBJ_NAME_TYPE_MD_METH,(char *)md); | ||
| 82 | if (r == 0) return(0); | ||
| 83 | r=OBJ_NAME_add(OBJ_nid2ln(md->type),OBJ_NAME_TYPE_MD_METH,(char *)md); | ||
| 84 | if (r == 0) return(0); | ||
| 85 | |||
| 86 | if (md->type != md->pkey_type) | ||
| 87 | { | ||
| 88 | r=OBJ_NAME_add(OBJ_nid2sn(md->pkey_type), | ||
| 89 | OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,name); | ||
| 90 | if (r == 0) return(0); | ||
| 91 | r=OBJ_NAME_add(OBJ_nid2ln(md->pkey_type), | ||
| 92 | OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,name); | ||
| 93 | } | ||
| 94 | return(r); | ||
| 95 | } | ||
| 96 | |||
| 97 | const EVP_CIPHER *EVP_get_cipherbyname(const char *name) | ||
| 98 | { | ||
| 99 | const EVP_CIPHER *cp; | ||
| 100 | |||
| 101 | cp=(const EVP_CIPHER *)OBJ_NAME_get(name,OBJ_NAME_TYPE_CIPHER_METH); | ||
| 102 | return(cp); | ||
| 103 | } | ||
| 104 | |||
| 105 | const EVP_MD *EVP_get_digestbyname(const char *name) | ||
| 106 | { | ||
| 107 | const EVP_MD *cp; | ||
| 108 | |||
| 109 | cp=(const EVP_MD *)OBJ_NAME_get(name,OBJ_NAME_TYPE_MD_METH); | ||
| 110 | return(cp); | ||
| 111 | } | ||
| 112 | |||
| 113 | void EVP_cleanup(void) | ||
| 114 | { | ||
| 115 | OBJ_NAME_cleanup(OBJ_NAME_TYPE_CIPHER_METH); | ||
| 116 | OBJ_NAME_cleanup(OBJ_NAME_TYPE_MD_METH); | ||
| 117 | /* The above calls will only clean out the contents of the name | ||
| 118 | hash table, but not the hash table itself. The following line | ||
| 119 | does that part. -- Richard Levitte */ | ||
| 120 | OBJ_NAME_cleanup(-1); | ||
| 121 | |||
| 122 | EVP_PBE_cleanup(); | ||
| 123 | } | ||
diff --git a/src/lib/libcrypto/evp/p5_crpt.c b/src/lib/libcrypto/evp/p5_crpt.c deleted file mode 100644 index e3dae52d4d..0000000000 --- a/src/lib/libcrypto/evp/p5_crpt.c +++ /dev/null | |||
| @@ -1,146 +0,0 @@ | |||
| 1 | /* p5_crpt.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include <stdlib.h> | ||
| 61 | #include <openssl/x509.h> | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | #include "cryptlib.h" | ||
| 64 | |||
| 65 | /* PKCS#5 v1.5 compatible PBE functions: see PKCS#5 v2.0 for more info. | ||
| 66 | */ | ||
| 67 | |||
| 68 | void PKCS5_PBE_add(void) | ||
| 69 | { | ||
| 70 | #ifndef NO_DES | ||
| 71 | # ifndef NO_MD5 | ||
| 72 | EVP_PBE_alg_add(NID_pbeWithMD5AndDES_CBC, EVP_des_cbc(), EVP_md5(), | ||
| 73 | PKCS5_PBE_keyivgen); | ||
| 74 | # endif | ||
| 75 | # ifndef NO_MD2 | ||
| 76 | EVP_PBE_alg_add(NID_pbeWithMD2AndDES_CBC, EVP_des_cbc(), EVP_md2(), | ||
| 77 | PKCS5_PBE_keyivgen); | ||
| 78 | # endif | ||
| 79 | # ifndef NO_SHA | ||
| 80 | EVP_PBE_alg_add(NID_pbeWithSHA1AndDES_CBC, EVP_des_cbc(), EVP_sha1(), | ||
| 81 | PKCS5_PBE_keyivgen); | ||
| 82 | # endif | ||
| 83 | #endif | ||
| 84 | #ifndef NO_RC2 | ||
| 85 | # ifndef NO_MD5 | ||
| 86 | EVP_PBE_alg_add(NID_pbeWithMD5AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md5(), | ||
| 87 | PKCS5_PBE_keyivgen); | ||
| 88 | # endif | ||
| 89 | # ifndef NO_MD2 | ||
| 90 | EVP_PBE_alg_add(NID_pbeWithMD2AndRC2_CBC, EVP_rc2_64_cbc(), EVP_md2(), | ||
| 91 | PKCS5_PBE_keyivgen); | ||
| 92 | # endif | ||
| 93 | # ifndef NO_SHA | ||
| 94 | EVP_PBE_alg_add(NID_pbeWithSHA1AndRC2_CBC, EVP_rc2_64_cbc(), EVP_sha1(), | ||
| 95 | PKCS5_PBE_keyivgen); | ||
| 96 | # endif | ||
| 97 | #endif | ||
| 98 | #ifndef NO_HMAC | ||
| 99 | EVP_PBE_alg_add(NID_pbes2, NULL, NULL, PKCS5_v2_PBE_keyivgen); | ||
| 100 | #endif | ||
| 101 | } | ||
| 102 | |||
| 103 | int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen, | ||
| 104 | ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md, | ||
| 105 | int en_de) | ||
| 106 | { | ||
| 107 | EVP_MD_CTX ctx; | ||
| 108 | unsigned char md_tmp[EVP_MAX_MD_SIZE]; | ||
| 109 | unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; | ||
| 110 | int i; | ||
| 111 | PBEPARAM *pbe; | ||
| 112 | int saltlen, iter; | ||
| 113 | unsigned char *salt, *pbuf; | ||
| 114 | |||
| 115 | /* Extract useful info from parameter */ | ||
| 116 | pbuf = param->value.sequence->data; | ||
| 117 | if (!param || (param->type != V_ASN1_SEQUENCE) || | ||
| 118 | !(pbe = d2i_PBEPARAM (NULL, &pbuf, param->value.sequence->length))) { | ||
| 119 | EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); | ||
| 120 | return 0; | ||
| 121 | } | ||
| 122 | |||
| 123 | if (!pbe->iter) iter = 1; | ||
| 124 | else iter = ASN1_INTEGER_get (pbe->iter); | ||
| 125 | salt = pbe->salt->data; | ||
| 126 | saltlen = pbe->salt->length; | ||
| 127 | |||
| 128 | EVP_DigestInit (&ctx, md); | ||
| 129 | EVP_DigestUpdate (&ctx, pass, passlen); | ||
| 130 | EVP_DigestUpdate (&ctx, salt, saltlen); | ||
| 131 | PBEPARAM_free(pbe); | ||
| 132 | EVP_DigestFinal (&ctx, md_tmp, NULL); | ||
| 133 | for (i = 1; i < iter; i++) { | ||
| 134 | EVP_DigestInit(&ctx, md); | ||
| 135 | EVP_DigestUpdate(&ctx, md_tmp, EVP_MD_size(md)); | ||
| 136 | EVP_DigestFinal (&ctx, md_tmp, NULL); | ||
| 137 | } | ||
| 138 | memcpy (key, md_tmp, EVP_CIPHER_key_length(cipher)); | ||
| 139 | memcpy (iv, md_tmp + (16 - EVP_CIPHER_iv_length(cipher)), | ||
| 140 | EVP_CIPHER_iv_length(cipher)); | ||
| 141 | EVP_CipherInit(cctx, cipher, key, iv, en_de); | ||
| 142 | memset(md_tmp, 0, EVP_MAX_MD_SIZE); | ||
| 143 | memset(key, 0, EVP_MAX_KEY_LENGTH); | ||
| 144 | memset(iv, 0, EVP_MAX_IV_LENGTH); | ||
| 145 | return 1; | ||
| 146 | } | ||
diff --git a/src/lib/libcrypto/evp/p5_crpt2.c b/src/lib/libcrypto/evp/p5_crpt2.c deleted file mode 100644 index 27a2c518be..0000000000 --- a/src/lib/libcrypto/evp/p5_crpt2.c +++ /dev/null | |||
| @@ -1,247 +0,0 @@ | |||
| 1 | /* p5_crpt2.c */ | ||
| 2 | /* Written by Dr Stephen N Henson (shenson@bigfoot.com) for the OpenSSL | ||
| 3 | * project 1999. | ||
| 4 | */ | ||
| 5 | /* ==================================================================== | ||
| 6 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 7 | * | ||
| 8 | * Redistribution and use in source and binary forms, with or without | ||
| 9 | * modification, are permitted provided that the following conditions | ||
| 10 | * are met: | ||
| 11 | * | ||
| 12 | * 1. Redistributions of source code must retain the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer. | ||
| 14 | * | ||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 16 | * notice, this list of conditions and the following disclaimer in | ||
| 17 | * the documentation and/or other materials provided with the | ||
| 18 | * distribution. | ||
| 19 | * | ||
| 20 | * 3. All advertising materials mentioning features or use of this | ||
| 21 | * software must display the following acknowledgment: | ||
| 22 | * "This product includes software developed by the OpenSSL Project | ||
| 23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 24 | * | ||
| 25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 26 | * endorse or promote products derived from this software without | ||
| 27 | * prior written permission. For written permission, please contact | ||
| 28 | * licensing@OpenSSL.org. | ||
| 29 | * | ||
| 30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 31 | * nor may "OpenSSL" appear in their names without prior written | ||
| 32 | * permission of the OpenSSL Project. | ||
| 33 | * | ||
| 34 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 35 | * acknowledgment: | ||
| 36 | * "This product includes software developed by the OpenSSL Project | ||
| 37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 38 | * | ||
| 39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 51 | * ==================================================================== | ||
| 52 | * | ||
| 53 | * This product includes cryptographic software written by Eric Young | ||
| 54 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 55 | * Hudson (tjh@cryptsoft.com). | ||
| 56 | * | ||
| 57 | */ | ||
| 58 | #if !defined(NO_HMAC) && !defined(NO_SHA) | ||
| 59 | #include <stdio.h> | ||
| 60 | #include <stdlib.h> | ||
| 61 | #include <openssl/x509.h> | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | #include <openssl/hmac.h> | ||
| 64 | #include "cryptlib.h" | ||
| 65 | |||
| 66 | /* set this to print out info about the keygen algorithm */ | ||
| 67 | /* #define DEBUG_PKCS5V2 */ | ||
| 68 | |||
| 69 | #ifdef DEBUG_PKCS5V2 | ||
| 70 | static void h__dump (const unsigned char *p, int len); | ||
| 71 | #endif | ||
| 72 | |||
| 73 | /* This is an implementation of PKCS#5 v2.0 password based encryption key | ||
| 74 | * derivation function PBKDF2 using the only currently defined function HMAC | ||
| 75 | * with SHA1. Verified against test vectors posted by Peter Gutmann | ||
| 76 | * <pgut001@cs.auckland.ac.nz> to the PKCS-TNG <pkcs-tng@rsa.com> mailing list. | ||
| 77 | */ | ||
| 78 | |||
| 79 | int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, | ||
| 80 | unsigned char *salt, int saltlen, int iter, | ||
| 81 | int keylen, unsigned char *out) | ||
| 82 | { | ||
| 83 | unsigned char digtmp[SHA_DIGEST_LENGTH], *p, itmp[4]; | ||
| 84 | int cplen, j, k, tkeylen; | ||
| 85 | unsigned long i = 1; | ||
| 86 | HMAC_CTX hctx; | ||
| 87 | p = out; | ||
| 88 | tkeylen = keylen; | ||
| 89 | if(passlen == -1) passlen = strlen(pass); | ||
| 90 | while(tkeylen) { | ||
| 91 | if(tkeylen > SHA_DIGEST_LENGTH) cplen = SHA_DIGEST_LENGTH; | ||
| 92 | else cplen = tkeylen; | ||
| 93 | /* We are unlikely to ever use more than 256 blocks (5120 bits!) | ||
| 94 | * but just in case... | ||
| 95 | */ | ||
| 96 | itmp[0] = (unsigned char)((i >> 24) & 0xff); | ||
| 97 | itmp[1] = (unsigned char)((i >> 16) & 0xff); | ||
| 98 | itmp[2] = (unsigned char)((i >> 8) & 0xff); | ||
| 99 | itmp[3] = (unsigned char)(i & 0xff); | ||
| 100 | HMAC_Init(&hctx, pass, passlen, EVP_sha1()); | ||
| 101 | HMAC_Update(&hctx, salt, saltlen); | ||
| 102 | HMAC_Update(&hctx, itmp, 4); | ||
| 103 | HMAC_Final(&hctx, digtmp, NULL); | ||
| 104 | memcpy(p, digtmp, cplen); | ||
| 105 | for(j = 1; j < iter; j++) { | ||
| 106 | HMAC(EVP_sha1(), pass, passlen, | ||
| 107 | digtmp, SHA_DIGEST_LENGTH, digtmp, NULL); | ||
| 108 | for(k = 0; k < cplen; k++) p[k] ^= digtmp[k]; | ||
| 109 | } | ||
| 110 | tkeylen-= cplen; | ||
| 111 | i++; | ||
| 112 | p+= cplen; | ||
| 113 | } | ||
| 114 | HMAC_cleanup(&hctx); | ||
| 115 | #ifdef DEBUG_PKCS5V2 | ||
| 116 | fprintf(stderr, "Password:\n"); | ||
| 117 | h__dump (pass, passlen); | ||
| 118 | fprintf(stderr, "Salt:\n"); | ||
| 119 | h__dump (salt, saltlen); | ||
| 120 | fprintf(stderr, "Iteration count %d\n", iter); | ||
| 121 | fprintf(stderr, "Key:\n"); | ||
| 122 | h__dump (out, keylen); | ||
| 123 | #endif | ||
| 124 | return 1; | ||
| 125 | } | ||
| 126 | |||
| 127 | #ifdef DO_TEST | ||
| 128 | main() | ||
| 129 | { | ||
| 130 | unsigned char out[4]; | ||
| 131 | unsigned char salt[] = {0x12, 0x34, 0x56, 0x78}; | ||
| 132 | PKCS5_PBKDF2_HMAC_SHA1("password", -1, salt, 4, 5, 4, out); | ||
| 133 | fprintf(stderr, "Out %02X %02X %02X %02X\n", | ||
| 134 | out[0], out[1], out[2], out[3]); | ||
| 135 | } | ||
| 136 | |||
| 137 | #endif | ||
| 138 | |||
| 139 | /* Now the key derivation function itself. This is a bit evil because | ||
| 140 | * it has to check the ASN1 parameters are valid: and there are quite a | ||
| 141 | * few of them... | ||
| 142 | */ | ||
| 143 | |||
| 144 | int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, | ||
| 145 | ASN1_TYPE *param, EVP_CIPHER *c, EVP_MD *md, | ||
| 146 | int en_de) | ||
| 147 | { | ||
| 148 | unsigned char *pbuf, *salt, key[EVP_MAX_KEY_LENGTH]; | ||
| 149 | int saltlen, keylen, iter, plen; | ||
| 150 | PBE2PARAM *pbe2 = NULL; | ||
| 151 | const EVP_CIPHER *cipher; | ||
| 152 | PBKDF2PARAM *kdf = NULL; | ||
| 153 | |||
| 154 | pbuf = param->value.sequence->data; | ||
| 155 | plen = param->value.sequence->length; | ||
| 156 | if(!param || (param->type != V_ASN1_SEQUENCE) || | ||
| 157 | !(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) { | ||
| 158 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); | ||
| 159 | return 0; | ||
| 160 | } | ||
| 161 | |||
| 162 | /* See if we recognise the key derivation function */ | ||
| 163 | |||
| 164 | if(OBJ_obj2nid(pbe2->keyfunc->algorithm) != NID_id_pbkdf2) { | ||
| 165 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
| 166 | EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION); | ||
| 167 | goto err; | ||
| 168 | } | ||
| 169 | |||
| 170 | /* lets see if we recognise the encryption algorithm. | ||
| 171 | */ | ||
| 172 | |||
| 173 | cipher = EVP_get_cipherbyname( | ||
| 174 | OBJ_nid2sn(OBJ_obj2nid(pbe2->encryption->algorithm))); | ||
| 175 | |||
| 176 | if(!cipher) { | ||
| 177 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
| 178 | EVP_R_UNSUPPORTED_CIPHER); | ||
| 179 | goto err; | ||
| 180 | } | ||
| 181 | |||
| 182 | /* Fixup cipher based on AlgorithmIdentifier */ | ||
| 183 | EVP_CipherInit(ctx, cipher, NULL, NULL, en_de); | ||
| 184 | if(EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) { | ||
| 185 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
| 186 | EVP_R_CIPHER_PARAMETER_ERROR); | ||
| 187 | goto err; | ||
| 188 | } | ||
| 189 | keylen = EVP_CIPHER_CTX_key_length(ctx); | ||
| 190 | |||
| 191 | /* Now decode key derivation function */ | ||
| 192 | |||
| 193 | pbuf = pbe2->keyfunc->parameter->value.sequence->data; | ||
| 194 | plen = pbe2->keyfunc->parameter->value.sequence->length; | ||
| 195 | if(!pbe2->keyfunc->parameter || | ||
| 196 | (pbe2->keyfunc->parameter->type != V_ASN1_SEQUENCE) || | ||
| 197 | !(kdf = d2i_PBKDF2PARAM(NULL, &pbuf, plen)) ) { | ||
| 198 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,EVP_R_DECODE_ERROR); | ||
| 199 | goto err; | ||
| 200 | } | ||
| 201 | |||
| 202 | PBE2PARAM_free(pbe2); | ||
| 203 | pbe2 = NULL; | ||
| 204 | |||
| 205 | /* Now check the parameters of the kdf */ | ||
| 206 | |||
| 207 | if(kdf->keylength && (ASN1_INTEGER_get(kdf->keylength) != keylen)){ | ||
| 208 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
| 209 | EVP_R_UNSUPPORTED_KEYLENGTH); | ||
| 210 | goto err; | ||
| 211 | } | ||
| 212 | |||
| 213 | if(kdf->prf && (OBJ_obj2nid(kdf->prf->algorithm) != NID_hmacWithSHA1)) { | ||
| 214 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_PRF); | ||
| 215 | goto err; | ||
| 216 | } | ||
| 217 | |||
| 218 | if(kdf->salt->type != V_ASN1_OCTET_STRING) { | ||
| 219 | EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, | ||
| 220 | EVP_R_UNSUPPORTED_SALT_TYPE); | ||
| 221 | goto err; | ||
| 222 | } | ||
| 223 | |||
| 224 | /* it seems that its all OK */ | ||
| 225 | salt = kdf->salt->value.octet_string->data; | ||
| 226 | saltlen = kdf->salt->value.octet_string->length; | ||
| 227 | iter = ASN1_INTEGER_get(kdf->iter); | ||
| 228 | PKCS5_PBKDF2_HMAC_SHA1(pass, passlen, salt, saltlen, iter, keylen, key); | ||
| 229 | EVP_CipherInit(ctx, NULL, key, NULL, en_de); | ||
| 230 | memset(key, 0, keylen); | ||
| 231 | PBKDF2PARAM_free(kdf); | ||
| 232 | return 1; | ||
| 233 | |||
| 234 | err: | ||
| 235 | PBE2PARAM_free(pbe2); | ||
| 236 | PBKDF2PARAM_free(kdf); | ||
| 237 | return 0; | ||
| 238 | } | ||
| 239 | |||
| 240 | #ifdef DEBUG_PKCS5V2 | ||
| 241 | static void h__dump (const unsigned char *p, int len) | ||
| 242 | { | ||
| 243 | for (; len --; p++) fprintf(stderr, "%02X ", *p); | ||
| 244 | fprintf(stderr, "\n"); | ||
| 245 | } | ||
| 246 | #endif | ||
| 247 | #endif | ||
diff --git a/src/lib/libcrypto/evp/p_dec.c b/src/lib/libcrypto/evp/p_dec.c deleted file mode 100644 index 57b5daa453..0000000000 --- a/src/lib/libcrypto/evp/p_dec.c +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | /* crypto/evp/p_dec.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/rand.h> | ||
| 62 | #ifndef NO_RSA | ||
| 63 | #include <openssl/rsa.h> | ||
| 64 | #endif | ||
| 65 | #include <openssl/evp.h> | ||
| 66 | #include <openssl/objects.h> | ||
| 67 | #include <openssl/x509.h> | ||
| 68 | |||
| 69 | int EVP_PKEY_decrypt(unsigned char *key, unsigned char *ek, int ekl, | ||
| 70 | EVP_PKEY *priv) | ||
| 71 | { | ||
| 72 | int ret= -1; | ||
| 73 | |||
| 74 | #ifndef NO_RSA | ||
| 75 | if (priv->type != EVP_PKEY_RSA) | ||
| 76 | { | ||
| 77 | #endif | ||
| 78 | EVPerr(EVP_F_EVP_PKEY_DECRYPT,EVP_R_PUBLIC_KEY_NOT_RSA); | ||
| 79 | #ifndef NO_RSA | ||
| 80 | goto err; | ||
| 81 | } | ||
| 82 | |||
| 83 | ret=RSA_private_decrypt(ekl,ek,key,priv->pkey.rsa,RSA_PKCS1_PADDING); | ||
| 84 | err: | ||
| 85 | #endif | ||
| 86 | return(ret); | ||
| 87 | } | ||
diff --git a/src/lib/libcrypto/evp/p_enc.c b/src/lib/libcrypto/evp/p_enc.c deleted file mode 100644 index 4cf6acaf5d..0000000000 --- a/src/lib/libcrypto/evp/p_enc.c +++ /dev/null | |||
| @@ -1,86 +0,0 @@ | |||
| 1 | /* crypto/evp/p_enc.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/rand.h> | ||
| 62 | #ifndef NO_RSA | ||
| 63 | #include <openssl/rsa.h> | ||
| 64 | #endif | ||
| 65 | #include <openssl/evp.h> | ||
| 66 | #include <openssl/objects.h> | ||
| 67 | #include <openssl/x509.h> | ||
| 68 | |||
| 69 | int EVP_PKEY_encrypt(unsigned char *ek, unsigned char *key, int key_len, | ||
| 70 | EVP_PKEY *pubk) | ||
| 71 | { | ||
| 72 | int ret=0; | ||
| 73 | |||
| 74 | #ifndef NO_RSA | ||
| 75 | if (pubk->type != EVP_PKEY_RSA) | ||
| 76 | { | ||
| 77 | #endif | ||
| 78 | EVPerr(EVP_F_EVP_PKEY_ENCRYPT,EVP_R_PUBLIC_KEY_NOT_RSA); | ||
| 79 | #ifndef NO_RSA | ||
| 80 | goto err; | ||
| 81 | } | ||
| 82 | ret=RSA_public_encrypt(key_len,key,ek,pubk->pkey.rsa,RSA_PKCS1_PADDING); | ||
| 83 | err: | ||
| 84 | #endif | ||
| 85 | return(ret); | ||
| 86 | } | ||
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c deleted file mode 100644 index 4cb387f8de..0000000000 --- a/src/lib/libcrypto/evp/p_lib.c +++ /dev/null | |||
| @@ -1,333 +0,0 @@ | |||
| 1 | /* crypto/evp/p_lib.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/objects.h> | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | #include <openssl/asn1_mac.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | |||
| 66 | static void EVP_PKEY_free_it(EVP_PKEY *x); | ||
| 67 | int EVP_PKEY_bits(EVP_PKEY *pkey) | ||
| 68 | { | ||
| 69 | #ifndef NO_RSA | ||
| 70 | if (pkey->type == EVP_PKEY_RSA) | ||
| 71 | return(BN_num_bits(pkey->pkey.rsa->n)); | ||
| 72 | else | ||
| 73 | #endif | ||
| 74 | #ifndef NO_DSA | ||
| 75 | if (pkey->type == EVP_PKEY_DSA) | ||
| 76 | return(BN_num_bits(pkey->pkey.dsa->p)); | ||
| 77 | #endif | ||
| 78 | return(0); | ||
| 79 | } | ||
| 80 | |||
| 81 | int EVP_PKEY_size(EVP_PKEY *pkey) | ||
| 82 | { | ||
| 83 | if (pkey == NULL) | ||
| 84 | return(0); | ||
| 85 | #ifndef NO_RSA | ||
| 86 | if (pkey->type == EVP_PKEY_RSA) | ||
| 87 | return(RSA_size(pkey->pkey.rsa)); | ||
| 88 | else | ||
| 89 | #endif | ||
| 90 | #ifndef NO_DSA | ||
| 91 | if (pkey->type == EVP_PKEY_DSA) | ||
| 92 | return(DSA_size(pkey->pkey.dsa)); | ||
| 93 | #endif | ||
| 94 | return(0); | ||
| 95 | } | ||
| 96 | |||
| 97 | int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode) | ||
| 98 | { | ||
| 99 | #ifndef NO_DSA | ||
| 100 | if (pkey->type == EVP_PKEY_DSA) | ||
| 101 | { | ||
| 102 | int ret=pkey->save_parameters=mode; | ||
| 103 | |||
| 104 | if (mode >= 0) | ||
| 105 | pkey->save_parameters=mode; | ||
| 106 | return(ret); | ||
| 107 | } | ||
| 108 | #endif | ||
| 109 | return(0); | ||
| 110 | } | ||
| 111 | |||
| 112 | int EVP_PKEY_copy_parameters(EVP_PKEY *to, EVP_PKEY *from) | ||
| 113 | { | ||
| 114 | if (to->type != from->type) | ||
| 115 | { | ||
| 116 | EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_DIFFERENT_KEY_TYPES); | ||
| 117 | goto err; | ||
| 118 | } | ||
| 119 | |||
| 120 | if (EVP_PKEY_missing_parameters(from)) | ||
| 121 | { | ||
| 122 | EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS); | ||
| 123 | goto err; | ||
| 124 | } | ||
| 125 | #ifndef NO_DSA | ||
| 126 | if (to->type == EVP_PKEY_DSA) | ||
| 127 | { | ||
| 128 | BIGNUM *a; | ||
| 129 | |||
| 130 | if ((a=BN_dup(from->pkey.dsa->p)) == NULL) goto err; | ||
| 131 | if (to->pkey.dsa->p != NULL) BN_free(to->pkey.dsa->p); | ||
| 132 | to->pkey.dsa->p=a; | ||
| 133 | |||
| 134 | if ((a=BN_dup(from->pkey.dsa->q)) == NULL) goto err; | ||
| 135 | if (to->pkey.dsa->q != NULL) BN_free(to->pkey.dsa->q); | ||
| 136 | to->pkey.dsa->q=a; | ||
| 137 | |||
| 138 | if ((a=BN_dup(from->pkey.dsa->g)) == NULL) goto err; | ||
| 139 | if (to->pkey.dsa->g != NULL) BN_free(to->pkey.dsa->g); | ||
| 140 | to->pkey.dsa->g=a; | ||
| 141 | } | ||
| 142 | #endif | ||
| 143 | return(1); | ||
| 144 | err: | ||
| 145 | return(0); | ||
| 146 | } | ||
| 147 | |||
| 148 | int EVP_PKEY_missing_parameters(EVP_PKEY *pkey) | ||
| 149 | { | ||
| 150 | #ifndef NO_DSA | ||
| 151 | if (pkey->type == EVP_PKEY_DSA) | ||
| 152 | { | ||
| 153 | DSA *dsa; | ||
| 154 | |||
| 155 | dsa=pkey->pkey.dsa; | ||
| 156 | if ((dsa->p == NULL) || (dsa->q == NULL) || (dsa->g == NULL)) | ||
| 157 | return(1); | ||
| 158 | } | ||
| 159 | #endif | ||
| 160 | return(0); | ||
| 161 | } | ||
| 162 | |||
| 163 | int EVP_PKEY_cmp_parameters(EVP_PKEY *a, EVP_PKEY *b) | ||
| 164 | { | ||
| 165 | #ifndef NO_DSA | ||
| 166 | if ((a->type == EVP_PKEY_DSA) && (b->type == EVP_PKEY_DSA)) | ||
| 167 | { | ||
| 168 | if ( BN_cmp(a->pkey.dsa->p,b->pkey.dsa->p) || | ||
| 169 | BN_cmp(a->pkey.dsa->q,b->pkey.dsa->q) || | ||
| 170 | BN_cmp(a->pkey.dsa->g,b->pkey.dsa->g)) | ||
| 171 | return(0); | ||
| 172 | else | ||
| 173 | return(1); | ||
| 174 | } | ||
| 175 | #endif | ||
| 176 | return(-1); | ||
| 177 | } | ||
| 178 | |||
| 179 | EVP_PKEY *EVP_PKEY_new(void) | ||
| 180 | { | ||
| 181 | EVP_PKEY *ret; | ||
| 182 | |||
| 183 | ret=(EVP_PKEY *)Malloc(sizeof(EVP_PKEY)); | ||
| 184 | if (ret == NULL) | ||
| 185 | { | ||
| 186 | EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE); | ||
| 187 | return(NULL); | ||
| 188 | } | ||
| 189 | ret->type=EVP_PKEY_NONE; | ||
| 190 | ret->references=1; | ||
| 191 | ret->pkey.ptr=NULL; | ||
| 192 | ret->attributes=NULL; | ||
| 193 | ret->save_parameters=1; | ||
| 194 | return(ret); | ||
| 195 | } | ||
| 196 | |||
| 197 | int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key) | ||
| 198 | { | ||
| 199 | if (pkey == NULL) return(0); | ||
| 200 | if (pkey->pkey.ptr != NULL) | ||
| 201 | EVP_PKEY_free_it(pkey); | ||
| 202 | pkey->type=EVP_PKEY_type(type); | ||
| 203 | pkey->save_type=type; | ||
| 204 | pkey->pkey.ptr=key; | ||
| 205 | return(key != NULL); | ||
| 206 | } | ||
| 207 | |||
| 208 | #ifndef NO_RSA | ||
| 209 | int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key) | ||
| 210 | { | ||
| 211 | int ret = EVP_PKEY_assign_RSA(pkey, key); | ||
| 212 | if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_RSA); | ||
| 213 | return ret; | ||
| 214 | } | ||
| 215 | |||
| 216 | RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey) | ||
| 217 | { | ||
| 218 | if(pkey->type != EVP_PKEY_RSA) { | ||
| 219 | EVPerr(EVP_F_EVP_PKEY_GET1_RSA, EVP_R_EXPECTING_AN_RSA_KEY); | ||
| 220 | return NULL; | ||
| 221 | } | ||
| 222 | CRYPTO_add(&pkey->pkey.rsa->references, 1, CRYPTO_LOCK_RSA); | ||
| 223 | return pkey->pkey.rsa; | ||
| 224 | } | ||
| 225 | #endif | ||
| 226 | |||
| 227 | #ifndef NO_DSA | ||
| 228 | int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key) | ||
| 229 | { | ||
| 230 | int ret = EVP_PKEY_assign_DSA(pkey, key); | ||
| 231 | if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DSA); | ||
| 232 | return ret; | ||
| 233 | } | ||
| 234 | |||
| 235 | DSA *EVP_PKEY_get1_DSA(EVP_PKEY *pkey) | ||
| 236 | { | ||
| 237 | if(pkey->type != EVP_PKEY_DSA) { | ||
| 238 | EVPerr(EVP_F_EVP_PKEY_GET1_DSA, EVP_R_EXPECTING_A_DSA_KEY); | ||
| 239 | return NULL; | ||
| 240 | } | ||
| 241 | CRYPTO_add(&pkey->pkey.dsa->references, 1, CRYPTO_LOCK_DSA); | ||
| 242 | return pkey->pkey.dsa; | ||
| 243 | } | ||
| 244 | #endif | ||
| 245 | |||
| 246 | #ifndef NO_DH | ||
| 247 | |||
| 248 | int EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key) | ||
| 249 | { | ||
| 250 | int ret = EVP_PKEY_assign_DH(pkey, key); | ||
| 251 | if(ret) CRYPTO_add(&key->references, 1, CRYPTO_LOCK_DH); | ||
| 252 | return ret; | ||
| 253 | } | ||
| 254 | |||
| 255 | DH *EVP_PKEY_get1_DH(EVP_PKEY *pkey) | ||
| 256 | { | ||
| 257 | if(pkey->type != EVP_PKEY_DH) { | ||
| 258 | EVPerr(EVP_F_EVP_PKEY_GET1_DH, EVP_R_EXPECTING_A_DH_KEY); | ||
| 259 | return NULL; | ||
| 260 | } | ||
| 261 | CRYPTO_add(&pkey->pkey.dh->references, 1, CRYPTO_LOCK_DH); | ||
| 262 | return pkey->pkey.dh; | ||
| 263 | } | ||
| 264 | #endif | ||
| 265 | |||
| 266 | int EVP_PKEY_type(int type) | ||
| 267 | { | ||
| 268 | switch (type) | ||
| 269 | { | ||
| 270 | case EVP_PKEY_RSA: | ||
| 271 | case EVP_PKEY_RSA2: | ||
| 272 | return(EVP_PKEY_RSA); | ||
| 273 | case EVP_PKEY_DSA: | ||
| 274 | case EVP_PKEY_DSA1: | ||
| 275 | case EVP_PKEY_DSA2: | ||
| 276 | case EVP_PKEY_DSA3: | ||
| 277 | case EVP_PKEY_DSA4: | ||
| 278 | return(EVP_PKEY_DSA); | ||
| 279 | case EVP_PKEY_DH: | ||
| 280 | return(EVP_PKEY_DH); | ||
| 281 | default: | ||
| 282 | return(NID_undef); | ||
| 283 | } | ||
| 284 | } | ||
| 285 | |||
| 286 | void EVP_PKEY_free(EVP_PKEY *x) | ||
| 287 | { | ||
| 288 | int i; | ||
| 289 | |||
| 290 | if (x == NULL) return; | ||
| 291 | |||
| 292 | i=CRYPTO_add(&x->references,-1,CRYPTO_LOCK_EVP_PKEY); | ||
| 293 | #ifdef REF_PRINT | ||
| 294 | REF_PRINT("EVP_PKEY",x); | ||
| 295 | #endif | ||
| 296 | if (i > 0) return; | ||
| 297 | #ifdef REF_CHECK | ||
| 298 | if (i < 0) | ||
| 299 | { | ||
| 300 | fprintf(stderr,"EVP_PKEY_free, bad reference count\n"); | ||
| 301 | abort(); | ||
| 302 | } | ||
| 303 | #endif | ||
| 304 | EVP_PKEY_free_it(x); | ||
| 305 | Free(x); | ||
| 306 | } | ||
| 307 | |||
| 308 | static void EVP_PKEY_free_it(EVP_PKEY *x) | ||
| 309 | { | ||
| 310 | switch (x->type) | ||
| 311 | { | ||
| 312 | #ifndef NO_RSA | ||
| 313 | case EVP_PKEY_RSA: | ||
| 314 | case EVP_PKEY_RSA2: | ||
| 315 | RSA_free(x->pkey.rsa); | ||
| 316 | break; | ||
| 317 | #endif | ||
| 318 | #ifndef NO_DSA | ||
| 319 | case EVP_PKEY_DSA: | ||
| 320 | case EVP_PKEY_DSA2: | ||
| 321 | case EVP_PKEY_DSA3: | ||
| 322 | case EVP_PKEY_DSA4: | ||
| 323 | DSA_free(x->pkey.dsa); | ||
| 324 | break; | ||
| 325 | #endif | ||
| 326 | #ifndef NO_DH | ||
| 327 | case EVP_PKEY_DH: | ||
| 328 | DH_free(x->pkey.dh); | ||
| 329 | break; | ||
| 330 | #endif | ||
| 331 | } | ||
| 332 | } | ||
| 333 | |||
diff --git a/src/lib/libcrypto/evp/p_open.c b/src/lib/libcrypto/evp/p_open.c deleted file mode 100644 index b9ca7892c2..0000000000 --- a/src/lib/libcrypto/evp/p_open.c +++ /dev/null | |||
| @@ -1,119 +0,0 @@ | |||
| 1 | /* crypto/evp/p_open.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #ifndef NO_RSA | ||
| 60 | #include <stdio.h> | ||
| 61 | #include "cryptlib.h" | ||
| 62 | #include <openssl/evp.h> | ||
| 63 | #include <openssl/objects.h> | ||
| 64 | #include <openssl/x509.h> | ||
| 65 | |||
| 66 | int EVP_OpenInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char *ek, | ||
| 67 | int ekl, unsigned char *iv, EVP_PKEY *priv) | ||
| 68 | { | ||
| 69 | unsigned char *key=NULL; | ||
| 70 | int i,size=0,ret=0; | ||
| 71 | |||
| 72 | if (priv->type != EVP_PKEY_RSA) | ||
| 73 | { | ||
| 74 | EVPerr(EVP_F_EVP_OPENINIT,EVP_R_PUBLIC_KEY_NOT_RSA); | ||
| 75 | ret= -1; | ||
| 76 | goto err; | ||
| 77 | } | ||
| 78 | |||
| 79 | size=RSA_size(priv->pkey.rsa); | ||
| 80 | key=(unsigned char *)Malloc(size+2); | ||
| 81 | if (key == NULL) | ||
| 82 | { | ||
| 83 | /* ERROR */ | ||
| 84 | EVPerr(EVP_F_EVP_OPENINIT,ERR_R_MALLOC_FAILURE); | ||
| 85 | ret= -1; | ||
| 86 | goto err; | ||
| 87 | } | ||
| 88 | |||
| 89 | i=EVP_PKEY_decrypt(key,ek,ekl,priv); | ||
| 90 | if (i != type->key_len) | ||
| 91 | { | ||
| 92 | /* ERROR */ | ||
| 93 | goto err; | ||
| 94 | } | ||
| 95 | |||
| 96 | EVP_CIPHER_CTX_init(ctx); | ||
| 97 | EVP_DecryptInit(ctx,type,key,iv); | ||
| 98 | ret=1; | ||
| 99 | err: | ||
| 100 | if (key != NULL) memset(key,0,size); | ||
| 101 | Free(key); | ||
| 102 | return(ret); | ||
| 103 | } | ||
| 104 | |||
| 105 | int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
| 106 | { | ||
| 107 | int i; | ||
| 108 | |||
| 109 | i=EVP_DecryptFinal(ctx,out,outl); | ||
| 110 | EVP_DecryptInit(ctx,NULL,NULL,NULL); | ||
| 111 | return(i); | ||
| 112 | } | ||
| 113 | #else /* !NO_RSA */ | ||
| 114 | |||
| 115 | # ifdef PEDANTIC | ||
| 116 | static void *dummy=&dummy; | ||
| 117 | # endif | ||
| 118 | |||
| 119 | #endif | ||
diff --git a/src/lib/libcrypto/evp/p_seal.c b/src/lib/libcrypto/evp/p_seal.c deleted file mode 100644 index d449e892bf..0000000000 --- a/src/lib/libcrypto/evp/p_seal.c +++ /dev/null | |||
| @@ -1,109 +0,0 @@ | |||
| 1 | /* crypto/evp/p_seal.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/rand.h> | ||
| 62 | #ifndef NO_RSA | ||
| 63 | #include <openssl/rsa.h> | ||
| 64 | #endif | ||
| 65 | #include <openssl/evp.h> | ||
| 66 | #include <openssl/objects.h> | ||
| 67 | #include <openssl/x509.h> | ||
| 68 | |||
| 69 | int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, | ||
| 70 | int *ekl, unsigned char *iv, EVP_PKEY **pubk, int npubk) | ||
| 71 | { | ||
| 72 | unsigned char key[EVP_MAX_KEY_LENGTH]; | ||
| 73 | int i; | ||
| 74 | |||
| 75 | if (npubk <= 0) return(0); | ||
| 76 | if (RAND_bytes(key,EVP_MAX_KEY_LENGTH) <= 0) | ||
| 77 | return(0); | ||
| 78 | if (type->iv_len > 0) | ||
| 79 | RAND_pseudo_bytes(iv,type->iv_len); | ||
| 80 | |||
| 81 | EVP_CIPHER_CTX_init(ctx); | ||
| 82 | EVP_EncryptInit(ctx,type,key,iv); | ||
| 83 | |||
| 84 | for (i=0; i<npubk; i++) | ||
| 85 | { | ||
| 86 | ekl[i]=EVP_PKEY_encrypt(ek[i],key,EVP_CIPHER_key_length(type), | ||
| 87 | pubk[i]); | ||
| 88 | if (ekl[i] <= 0) return(-1); | ||
| 89 | } | ||
| 90 | return(npubk); | ||
| 91 | } | ||
| 92 | |||
| 93 | /* MACRO | ||
| 94 | void EVP_SealUpdate(ctx,out,outl,in,inl) | ||
| 95 | EVP_CIPHER_CTX *ctx; | ||
| 96 | unsigned char *out; | ||
| 97 | int *outl; | ||
| 98 | unsigned char *in; | ||
| 99 | int inl; | ||
| 100 | { | ||
| 101 | EVP_EncryptUpdate(ctx,out,outl,in,inl); | ||
| 102 | } | ||
| 103 | */ | ||
| 104 | |||
| 105 | void EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) | ||
| 106 | { | ||
| 107 | EVP_EncryptFinal(ctx,out,outl); | ||
| 108 | EVP_EncryptInit(ctx,NULL,NULL,NULL); | ||
| 109 | } | ||
diff --git a/src/lib/libcrypto/evp/p_sign.c b/src/lib/libcrypto/evp/p_sign.c deleted file mode 100644 index 1fa32ac17e..0000000000 --- a/src/lib/libcrypto/evp/p_sign.c +++ /dev/null | |||
| @@ -1,112 +0,0 @@ | |||
| 1 | /* crypto/evp/p_sign.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/x509.h> | ||
| 64 | |||
| 65 | #ifdef undef | ||
| 66 | void EVP_SignInit(EVP_MD_CTX *ctx, EVP_MD *type) | ||
| 67 | { | ||
| 68 | EVP_DigestInit(ctx,type); | ||
| 69 | } | ||
| 70 | |||
| 71 | void EVP_SignUpdate(EVP_MD_CTX *ctx, unsigned char *data, | ||
| 72 | unsigned int count) | ||
| 73 | { | ||
| 74 | EVP_DigestUpdate(ctx,data,count); | ||
| 75 | } | ||
| 76 | #endif | ||
| 77 | |||
| 78 | int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, unsigned int *siglen, | ||
| 79 | EVP_PKEY *pkey) | ||
| 80 | { | ||
| 81 | unsigned char m[EVP_MAX_MD_SIZE]; | ||
| 82 | unsigned int m_len; | ||
| 83 | int i,ok=0,v; | ||
| 84 | MS_STATIC EVP_MD_CTX tmp_ctx; | ||
| 85 | |||
| 86 | *siglen=0; | ||
| 87 | EVP_MD_CTX_copy(&tmp_ctx,ctx); | ||
| 88 | EVP_DigestFinal(&tmp_ctx,&(m[0]),&m_len); | ||
| 89 | for (i=0; i<4; i++) | ||
| 90 | { | ||
| 91 | v=ctx->digest->required_pkey_type[i]; | ||
| 92 | if (v == 0) break; | ||
| 93 | if (pkey->type == v) | ||
| 94 | { | ||
| 95 | ok=1; | ||
| 96 | break; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | if (!ok) | ||
| 100 | { | ||
| 101 | EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); | ||
| 102 | return(0); | ||
| 103 | } | ||
| 104 | if (ctx->digest->sign == NULL) | ||
| 105 | { | ||
| 106 | EVPerr(EVP_F_EVP_SIGNFINAL,EVP_R_NO_SIGN_FUNCTION_CONFIGURED); | ||
| 107 | return(0); | ||
| 108 | } | ||
| 109 | return(ctx->digest->sign(ctx->digest->type,m,m_len,sigret,siglen, | ||
| 110 | pkey->pkey.ptr)); | ||
| 111 | } | ||
| 112 | |||
diff --git a/src/lib/libcrypto/evp/p_verify.c b/src/lib/libcrypto/evp/p_verify.c deleted file mode 100644 index dcb54f3abb..0000000000 --- a/src/lib/libcrypto/evp/p_verify.c +++ /dev/null | |||
| @@ -1,99 +0,0 @@ | |||
| 1 | /* crypto/evp/p_verify.c */ | ||
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | ||
| 3 | * All rights reserved. | ||
| 4 | * | ||
| 5 | * This package is an SSL implementation written | ||
| 6 | * by Eric Young (eay@cryptsoft.com). | ||
| 7 | * The implementation was written so as to conform with Netscapes SSL. | ||
| 8 | * | ||
| 9 | * This library is free for commercial and non-commercial use as long as | ||
| 10 | * the following conditions are aheared to. The following conditions | ||
| 11 | * apply to all code found in this distribution, be it the RC4, RSA, | ||
| 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 13 | * included with this distribution is covered by the same copyright terms | ||
| 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 15 | * | ||
| 16 | * Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 17 | * the code are not to be removed. | ||
| 18 | * If this package is used in a product, Eric Young should be given attribution | ||
| 19 | * as the author of the parts of the library used. | ||
| 20 | * This can be in the form of a textual message at program startup or | ||
| 21 | * in documentation (online or textual) provided with the package. | ||
| 22 | * | ||
| 23 | * Redistribution and use in source and binary forms, with or without | ||
| 24 | * modification, are permitted provided that the following conditions | ||
| 25 | * are met: | ||
| 26 | * 1. Redistributions of source code must retain the copyright | ||
| 27 | * notice, this list of conditions and the following disclaimer. | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 29 | * notice, this list of conditions and the following disclaimer in the | ||
| 30 | * documentation and/or other materials provided with the distribution. | ||
| 31 | * 3. All advertising materials mentioning features or use of this software | ||
| 32 | * must display the following acknowledgement: | ||
| 33 | * "This product includes cryptographic software written by | ||
| 34 | * Eric Young (eay@cryptsoft.com)" | ||
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | ||
| 36 | * being used are not cryptographic related :-). | ||
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | ||
| 38 | * the apps directory (application code) you must include an acknowledgement: | ||
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | ||
| 40 | * | ||
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 51 | * SUCH DAMAGE. | ||
| 52 | * | ||
| 53 | * The licence and distribution terms for any publically available version or | ||
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 55 | * copied and put under another distribution licence | ||
| 56 | * [including the GNU Public Licence.] | ||
| 57 | */ | ||
| 58 | |||
| 59 | #include <stdio.h> | ||
| 60 | #include "cryptlib.h" | ||
| 61 | #include <openssl/evp.h> | ||
| 62 | #include <openssl/objects.h> | ||
| 63 | #include <openssl/x509.h> | ||
| 64 | |||
| 65 | int EVP_VerifyFinal(EVP_MD_CTX *ctx, unsigned char *sigbuf, | ||
| 66 | unsigned int siglen, EVP_PKEY *pkey) | ||
| 67 | { | ||
| 68 | unsigned char m[EVP_MAX_MD_SIZE]; | ||
| 69 | unsigned int m_len; | ||
| 70 | int i,ok=0,v; | ||
| 71 | MS_STATIC EVP_MD_CTX tmp_ctx; | ||
| 72 | |||
| 73 | for (i=0; i<4; i++) | ||
| 74 | { | ||
| 75 | v=ctx->digest->required_pkey_type[i]; | ||
| 76 | if (v == 0) break; | ||
| 77 | if (pkey->type == v) | ||
| 78 | { | ||
| 79 | ok=1; | ||
| 80 | break; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | if (!ok) | ||
| 84 | { | ||
| 85 | EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_WRONG_PUBLIC_KEY_TYPE); | ||
| 86 | return(-1); | ||
| 87 | } | ||
| 88 | EVP_MD_CTX_copy(&tmp_ctx,ctx); | ||
| 89 | EVP_DigestFinal(&tmp_ctx,&(m[0]),&m_len); | ||
| 90 | if (ctx->digest->verify == NULL) | ||
| 91 | { | ||
| 92 | EVPerr(EVP_F_EVP_VERIFYFINAL,EVP_R_NO_VERIFY_FUNCTION_CONFIGURED); | ||
| 93 | return(0); | ||
| 94 | } | ||
| 95 | |||
| 96 | return(ctx->digest->verify(ctx->digest->type,m,m_len, | ||
| 97 | sigbuf,siglen,pkey->pkey.ptr)); | ||
| 98 | } | ||
| 99 | |||
