diff options
| author | markus <> | 2002-09-05 12:51:50 +0000 |
|---|---|---|
| committer | markus <> | 2002-09-05 12:51:50 +0000 |
| commit | 15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch) | |
| tree | bf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libcrypto/rsa/rsa_none.c | |
| parent | 027351f729b9e837200dae6e1520cda6577ab930 (diff) | |
| download | openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2 openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip | |
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_none.c')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_none.c | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_none.c b/src/lib/libcrypto/rsa/rsa_none.c index f0dd943657..e6f3e627ca 100644 --- a/src/lib/libcrypto/rsa/rsa_none.c +++ b/src/lib/libcrypto/rsa/rsa_none.c | |||
| @@ -58,52 +58,41 @@ | |||
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include "cryptlib.h" | 60 | #include "cryptlib.h" |
| 61 | #include "bn.h" | 61 | #include <openssl/bn.h> |
| 62 | #include "rsa.h" | 62 | #include <openssl/rsa.h> |
| 63 | #include "rand.h" | 63 | #include <openssl/rand.h> |
| 64 | 64 | ||
| 65 | int RSA_padding_add_none(to,tlen,from,flen) | 65 | int RSA_padding_add_none(unsigned char *to, int tlen, |
| 66 | unsigned char *to; | 66 | const unsigned char *from, int flen) |
| 67 | int tlen; | ||
| 68 | unsigned char *from; | ||
| 69 | int flen; | ||
| 70 | { | 67 | { |
| 71 | if (flen >= tlen) | 68 | if (flen > tlen) |
| 72 | { | 69 | { |
| 73 | RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); | 70 | RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE); |
| 74 | return(0); | 71 | return(0); |
| 75 | } | 72 | } |
| 73 | |||
| 74 | if (flen < tlen) | ||
| 75 | { | ||
| 76 | RSAerr(RSA_F_RSA_PADDING_ADD_NONE,RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE); | ||
| 77 | return(0); | ||
| 78 | } | ||
| 76 | 79 | ||
| 77 | *(to++)=0; | ||
| 78 | memcpy(to,from,(unsigned int)flen); | 80 | memcpy(to,from,(unsigned int)flen); |
| 79 | return(1); | 81 | return(1); |
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | int RSA_padding_check_none(to,tlen,from,flen) | 84 | int RSA_padding_check_none(unsigned char *to, int tlen, |
| 83 | unsigned char *to; | 85 | const unsigned char *from, int flen, int num) |
| 84 | int tlen; | ||
| 85 | unsigned char *from; | ||
| 86 | int flen; | ||
| 87 | { | 86 | { |
| 88 | int j; | ||
| 89 | 87 | ||
| 90 | from++; | 88 | if (flen > tlen) |
| 91 | if (flen+1 > tlen) | ||
| 92 | { | 89 | { |
| 93 | RSAerr(RSA_F_RSA_PADDING_CHECK_NONE,RSA_R_DATA_TOO_LARGE); | 90 | RSAerr(RSA_F_RSA_PADDING_CHECK_NONE,RSA_R_DATA_TOO_LARGE); |
| 94 | return(-1); | 91 | return(-1); |
| 95 | } | 92 | } |
| 96 | if (*(from++) != 0) | ||
| 97 | { | ||
| 98 | RSAerr(RSA_F_RSA_PADDING_CHECK_NONE,RSA_R_BAD_ZERO_BYTE); | ||
| 99 | return(-1); | ||
| 100 | } | ||
| 101 | 93 | ||
| 102 | /* scan over padding data */ | 94 | memset(to,0,tlen-flen); |
| 103 | j=flen-1; /* one for type and one for the prepended 0. */ | 95 | memcpy(to+tlen-flen,from,flen); |
| 104 | memset(to,0,tlen-j); | 96 | return(tlen); |
| 105 | to+=(tlen-j); | ||
| 106 | memcpy(to,from,j); | ||
| 107 | return(j); | ||
| 108 | } | 97 | } |
| 109 | 98 | ||
