diff options
author | cvs2hg <devnull@localhost> | 2007-01-17 18:58:58 +0000 |
---|---|---|
committer | cvs2hg <devnull@localhost> | 2007-01-17 18:58:58 +0000 |
commit | 93e159f0223690f2a1600e373b4981960ff98c76 (patch) | |
tree | 29b49ea46f1e4cae8952c958a85a1d50399ea264 /security/nss/lib/softoken/ecdecode.c | |
parent | efc6ec73fd3a32a186e55ad5da2cb9e383c8676e (diff) | |
download | nss-hg-93e159f0223690f2a1600e373b4981960ff98c76.tar.gz |
fixup commit for branch 'GECKO180_20071210_RELBRANCH'
Diffstat (limited to 'security/nss/lib/softoken/ecdecode.c')
-rw-r--r-- | security/nss/lib/softoken/ecdecode.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/security/nss/lib/softoken/ecdecode.c b/security/nss/lib/softoken/ecdecode.c index e649ff899..dbf1cb3f8 100644 --- a/security/nss/lib/softoken/ecdecode.c +++ b/security/nss/lib/softoken/ecdecode.c @@ -49,7 +49,12 @@ #define CHECK_OK(func) if (func == NULL) goto cleanup #define CHECK_SEC_OK(func) if (SECSuccess != (rv = func)) goto cleanup -/* Initializes a SECItem from a hexadecimal string */ +/* + * Initializes a SECItem from a hexadecimal string + * + * Warning: This function ignores leading 00's, so any leading 00's + * in the hexadecimal string must be optional. + */ static SECItem * hexString2SECItem(PRArenaPool *arena, SECItem *item, const char *str) { @@ -59,6 +64,12 @@ hexString2SECItem(PRArenaPool *arena, SECItem *item, const char *str) if ((tmp % 2) != 0) return NULL; + /* skip leading 00's unless the hex string is "00" */ + while ((tmp > 2) && (str[0] == '0') && (str[1] == '0')) { + str += 2; + tmp -= 2; + } + item->data = (unsigned char *) PORT_ArenaAlloc(arena, tmp/2); if (item->data == NULL) return NULL; item->len = tmp/2; @@ -136,7 +147,8 @@ EC_FillParams(PRArenaPool *arena, const SECItem *encodedParams, SECOidTag tag; SECItem oid = { siBuffer, NULL, 0}; const ECCurveParams *curveParams; - char genenc[2 + 2 * 2 * MAX_ECKEY_LEN]; + /* 2 ['0'+'4'] + MAX_ECKEY_LEN * 2 [x,y] * 2 [hex string] + 1 ['\0'] */ + char genenc[3 + 2 * 2 * MAX_ECKEY_LEN]; #if EC_DEBUG int i; |