Mercurial > dropbear
comparison pkcs_1_v15_es_decode.c @ 143:5d99163f7e32 libtomcrypt-orig
import of libtomcrypt 0.99
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 19 Dec 2004 11:34:45 +0000 |
parents | 6362d3854bb4 |
children |
comparison
equal
deleted
inserted
replaced
15:6362d3854bb4 | 143:5d99163f7e32 |
---|---|
26 _ARGCHK(res != NULL); | 26 _ARGCHK(res != NULL); |
27 | 27 |
28 /* default to failed */ | 28 /* default to failed */ |
29 *res = 0; | 29 *res = 0; |
30 | 30 |
31 /* must be at least 12 bytes long */ | 31 modulus_bytelen = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0); |
32 if (msglen < 12) { | 32 |
33 /* must be at least modulus_bytelen bytes long */ | |
34 if (msglen != modulus_bytelen) { | |
33 return CRYPT_INVALID_ARG; | 35 return CRYPT_INVALID_ARG; |
34 } | 36 } |
35 | |
36 modulus_bytelen = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0); | |
37 | 37 |
38 /* should start with 0x00 0x02 */ | 38 /* should start with 0x00 0x02 */ |
39 if (msg[0] != 0x00 || msg[1] != 0x02) { | 39 if (msg[0] != 0x00 || msg[1] != 0x02) { |
40 return CRYPT_OK; | 40 return CRYPT_OK; |
41 } | 41 } |
50 | 50 |
51 /* the message is left */ | 51 /* the message is left */ |
52 if (x + outlen > modulus_bytelen) { | 52 if (x + outlen > modulus_bytelen) { |
53 return CRYPT_PK_INVALID_SIZE; | 53 return CRYPT_PK_INVALID_SIZE; |
54 } | 54 } |
55 memcpy(out, msg + x, outlen); | 55 XMEMCPY(out, msg + x, outlen); |
56 *res = 1; | 56 *res = 1; |
57 return CRYPT_OK; | 57 return CRYPT_OK; |
58 } | 58 } |
59 | 59 |
60 #endif | 60 #endif |