aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-04-05 17:10:48 +0000
committerNick Mathewson <nickm@torproject.org>2004-04-05 17:10:48 +0000
commit84b9e90d5f17252e6c919a10482063ffd8c8e41c (patch)
tree696c2ebba19d4ce28317f745c106c8b0c48cb064
parentcebf16eaf01d9dea65b0252f36e33514bdd6f84e (diff)
downloadtor-84b9e90d5f17252e6c919a10482063ffd8c8e41c.tar
tor-84b9e90d5f17252e6c919a10482063ffd8c8e41c.tar.gz
i2d_RSAPublicKey advances the pointer it receives past the ASN1-encoded string.
svn:r1478
-rw-r--r--src/common/crypto.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index a666d4abe..7e642df35 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -638,12 +638,12 @@ int crypto_pk_private_hybrid_decrypt(crypto_pk_env_t *env,
int crypto_pk_asn1_encode(crypto_pk_env_t *pk, char *dest, int dest_len)
{
int len;
- unsigned char *buf, *bufp;
+ unsigned char *buf, *cp;
len = i2d_RSAPublicKey(pk->key, NULL);
if (len < 0 || len > dest_len)
return -1;
- bufp = buf = tor_malloc(len+1);
- len = i2d_RSAPublicKey(pk->key, &bufp);
+ cp = buf = tor_malloc(len+1);
+ len = i2d_RSAPublicKey(pk->key, &cp);
if (len < 0) {
tor_free(buf);
return -1;
@@ -662,17 +662,17 @@ crypto_pk_env_t *crypto_pk_asn1_decode(const char *str, int len)
{
RSA *rsa;
unsigned char *buf;
- const unsigned char *bufp;
- bufp = buf = tor_malloc(len);
- memcpy(buf,str,len);
/* This ifdef suppresses a type warning. Take out the first case once
* everybody is using openssl 0.9.7 or later.
*/
#if OPENSSL_VERSION_NUMBER < 0x00907000l
- rsa = d2i_RSAPublicKey(NULL, &buf, len);
+ unsigned char *cp;
#else
- rsa = d2i_RSAPublicKey(NULL, &bufp, len);
+ const unsigned char *cp;
#endif
+ cp = buf = tor_malloc(len);
+ memcpy(buf,str,len);
+ rsa = d2i_RSAPublicKey(NULL, &cp, len);
tor_free(buf);
if (!rsa)
return NULL; /* XXXX log openssl error */