X-Git-Url: https://git.openssl.org/?a=blobdiff_plain;f=crypto%2Fec%2Fec_key.c;h=57388da91ea408dadc3f2c4051f107738d83779d;hb=7fc7d1a7bdeda7e448c13e6fecce96a53b7a62d2;hp=19628b143539167f633dfa712d09c3d026cd49d3;hpb=ac3e3665016e4441475276461d5f910eb9e9ea15;p=openssl.git diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 19628b1435..57388da91e 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -591,3 +591,22 @@ int EC_KEY_oct2priv(EC_KEY *eckey, unsigned char *buf, size_t len) } return 1; } + +size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf) +{ + size_t len; + unsigned char *buf; + len = EC_KEY_priv2oct(eckey, NULL, 0); + if (len == 0) + return 0; + buf = OPENSSL_malloc(len); + if (buf == NULL) + return 0; + len = EC_KEY_priv2oct(eckey, buf, len); + if (len == 0) { + OPENSSL_free(buf); + return 0; + } + *pbuf = buf; + return len; +}