mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
getter function for X509 public key
This commit is contained in:
32
src/ssl.c
32
src/ssl.c
@ -15318,7 +15318,8 @@ WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len)
|
||||
unsigned char* buf, int* bufSz)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_X509_get_signature");
|
||||
if (x509 == NULL || bufSz == NULL || *bufSz < (int)x509->sig.length)
|
||||
if (x509 == NULL || bufSz == NULL || (*bufSz < (int)x509->sig.length &&
|
||||
buf != NULL))
|
||||
return WOLFSSL_FATAL_ERROR;
|
||||
|
||||
if (buf != NULL)
|
||||
@ -15329,6 +15330,35 @@ WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len)
|
||||
}
|
||||
|
||||
|
||||
/* Getter function that copies over the DER public key buffer to "buf" and
|
||||
* sets the size in bufSz. If "buf" is NULL then just bufSz is set to needed
|
||||
* buffer size.
|
||||
* return WOLFSSL_SUCCESS on success
|
||||
*/
|
||||
int wolfSSL_X509_get_pubkey_buffer(WOLFSSL_X509* x509,
|
||||
unsigned char* buf, int* bufSz)
|
||||
{
|
||||
WOLFSSL_ENTER("wolfSSL_X509_get_pubkey_buffer");
|
||||
if (x509 == NULL || bufSz == NULL || (*bufSz < (int)x509->pubKey.length
|
||||
&& buf != NULL))
|
||||
return WOLFSSL_FATAL_ERROR;
|
||||
|
||||
if (buf != NULL)
|
||||
XMEMCPY(buf, x509->pubKey.buffer, x509->pubKey.length);
|
||||
*bufSz = x509->pubKey.length;
|
||||
|
||||
return WOLFSSL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* Getter function for the public key OID value
|
||||
* return public key OID stored in WOLFSSL_X509 structure */
|
||||
int wolfSSL_X509_get_pubkey_type(WOLFSSL_X509* x509)
|
||||
{
|
||||
return x509->pubKeyOID;
|
||||
}
|
||||
|
||||
|
||||
/* write X509 serial number in unsigned binary to buffer
|
||||
buffer needs to be at least EXTERNAL_SERIAL_SIZE (32) for all cases
|
||||
return WOLFSSL_SUCCESS on success */
|
||||
|
@ -952,6 +952,9 @@ WOLFSSL_API int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX*);
|
||||
WOLFSSL_API const char* wolfSSL_X509_verify_cert_error_string(long);
|
||||
WOLFSSL_API int wolfSSL_X509_get_signature_type(WOLFSSL_X509*);
|
||||
WOLFSSL_API int wolfSSL_X509_get_signature(WOLFSSL_X509*, unsigned char*, int*);
|
||||
WOLFSSL_API int wolfSSL_X509_get_pubkey_buffer(WOLFSSL_X509*, unsigned char*,
|
||||
int*);
|
||||
WOLFSSL_API int wolfSSL_X509_get_pubkey_type(WOLFSSL_X509* x509);
|
||||
|
||||
WOLFSSL_API int wolfSSL_X509_LOOKUP_add_dir(WOLFSSL_X509_LOOKUP*,const char*,long);
|
||||
WOLFSSL_API int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP*, const char*,
|
||||
|
Reference in New Issue
Block a user