- Moved storing of a printable serial into a separate function
This commit is contained in:
parent
72f6266f02
commit
dd47699ba5
@ -593,6 +593,19 @@ int x509parse_dhmfile( dhm_context *rsa, const char *path );
|
|||||||
*/
|
*/
|
||||||
int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn );
|
int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Store the certificate serial in printable form into buf;
|
||||||
|
* no more than size characters will be written.
|
||||||
|
*
|
||||||
|
* \param buf Buffer to write to
|
||||||
|
* \param size Maximum size of buffer
|
||||||
|
* \param serial The X509 serial to represent
|
||||||
|
*
|
||||||
|
* \return The amount of data written to the buffer, or -1 in
|
||||||
|
* case of an error.
|
||||||
|
*/
|
||||||
|
int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns an informational string about the
|
* \brief Returns an informational string about the
|
||||||
* certificate.
|
* certificate.
|
||||||
|
@ -2305,13 +2305,38 @@ int x509parse_dn_gets( char *buf, size_t size, const x509_name *dn )
|
|||||||
return( size - n );
|
return( size - n );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store the serial in printable form into buf; no more
|
||||||
|
* than size characters will be written
|
||||||
|
*/
|
||||||
|
int x509parse_serial_gets( char *buf, size_t size, const x509_buf *serial )
|
||||||
|
{
|
||||||
|
int i, ret, nr, n;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
p = buf;
|
||||||
|
n = size;
|
||||||
|
|
||||||
|
nr = ( serial->len <= 32 )
|
||||||
|
? serial->len : 32;
|
||||||
|
|
||||||
|
for( i = 0; i < nr; i++ )
|
||||||
|
{
|
||||||
|
ret = snprintf( p, n, "%02X%s",
|
||||||
|
serial->p[i], ( i < nr - 1 ) ? ":" : "" );
|
||||||
|
SAFE_SNPRINTF();
|
||||||
|
}
|
||||||
|
|
||||||
|
return( size - n );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return an informational string about the certificate.
|
* Return an informational string about the certificate.
|
||||||
*/
|
*/
|
||||||
int x509parse_cert_info( char *buf, size_t size, const char *prefix,
|
int x509parse_cert_info( char *buf, size_t size, const char *prefix,
|
||||||
const x509_cert *crt )
|
const x509_cert *crt )
|
||||||
{
|
{
|
||||||
int i, n, nr, ret;
|
int n, ret;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
@ -2324,15 +2349,8 @@ int x509parse_cert_info( char *buf, size_t size, const char *prefix,
|
|||||||
prefix );
|
prefix );
|
||||||
SAFE_SNPRINTF();
|
SAFE_SNPRINTF();
|
||||||
|
|
||||||
nr = ( crt->serial.len <= 32 )
|
ret = x509parse_serial_gets( p, n, &crt->serial);
|
||||||
? crt->serial.len : 32;
|
|
||||||
|
|
||||||
for( i = 0; i < nr; i++ )
|
|
||||||
{
|
|
||||||
ret = snprintf( p, n, "%02X%s",
|
|
||||||
crt->serial.p[i], ( i < nr - 1 ) ? ":" : "" );
|
|
||||||
SAFE_SNPRINTF();
|
SAFE_SNPRINTF();
|
||||||
}
|
|
||||||
|
|
||||||
ret = snprintf( p, n, "\n%sissuer name : ", prefix );
|
ret = snprintf( p, n, "\n%sissuer name : ", prefix );
|
||||||
SAFE_SNPRINTF();
|
SAFE_SNPRINTF();
|
||||||
|
Loading…
Reference in New Issue
Block a user