Mercurial > dropbear
diff 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 |
line wrap: on
line diff
--- a/pkcs_1_v15_es_decode.c Tue Jun 15 14:07:21 2004 +0000 +++ b/pkcs_1_v15_es_decode.c Sun Dec 19 11:34:45 2004 +0000 @@ -28,13 +28,13 @@ /* default to failed */ *res = 0; - /* must be at least 12 bytes long */ - if (msglen < 12) { + modulus_bytelen = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0); + + /* must be at least modulus_bytelen bytes long */ + if (msglen != modulus_bytelen) { return CRYPT_INVALID_ARG; } - modulus_bytelen = (modulus_bitlen>>3) + (modulus_bitlen & 7 ? 1 : 0); - /* should start with 0x00 0x02 */ if (msg[0] != 0x00 || msg[1] != 0x02) { return CRYPT_OK; @@ -52,7 +52,7 @@ if (x + outlen > modulus_bytelen) { return CRYPT_PK_INVALID_SIZE; } - memcpy(out, msg + x, outlen); + XMEMCPY(out, msg + x, outlen); *res = 1; return CRYPT_OK; }