Changes x509_csr to x509write_csr
This commit is contained in:
parent
5f45e62afe
commit
cd35803684
@ -63,14 +63,14 @@ extern "C" {
|
||||
/**
|
||||
* Container for a CSR
|
||||
*/
|
||||
typedef struct _x509_csr
|
||||
typedef struct _x509write_csr
|
||||
{
|
||||
rsa_context *rsa;
|
||||
asn1_named_data *subject;
|
||||
md_type_t md_alg;
|
||||
asn1_named_data *extensions;
|
||||
}
|
||||
x509_csr;
|
||||
x509write_csr;
|
||||
|
||||
#define X509_CRT_VERSION_1 0
|
||||
#define X509_CRT_VERSION_2 1
|
||||
@ -104,7 +104,7 @@ x509write_cert;
|
||||
*
|
||||
* \param ctx CSR context to initialize
|
||||
*/
|
||||
void x509write_csr_init( x509_csr *ctx );
|
||||
void x509write_csr_init( x509write_csr *ctx );
|
||||
|
||||
/**
|
||||
* \brief Set the subject name for a CSR
|
||||
@ -118,7 +118,7 @@ void x509write_csr_init( x509_csr *ctx );
|
||||
* \return 0 if subject name was parsed successfully, or
|
||||
* a specific error code
|
||||
*/
|
||||
int x509write_csr_set_subject_name( x509_csr *ctx, char *subject_name );
|
||||
int x509write_csr_set_subject_name( x509write_csr *ctx, char *subject_name );
|
||||
|
||||
/**
|
||||
* \brief Set the RSA key for a CSR (public key will be included,
|
||||
@ -127,7 +127,7 @@ int x509write_csr_set_subject_name( x509_csr *ctx, char *subject_name );
|
||||
* \param ctx CSR context to use
|
||||
* \param rsa RSA key to include
|
||||
*/
|
||||
void x509write_csr_set_rsa_key( x509_csr *ctx, rsa_context *rsa );
|
||||
void x509write_csr_set_rsa_key( x509write_csr *ctx, rsa_context *rsa );
|
||||
|
||||
/**
|
||||
* \brief Set the MD algorithm to use for the signature
|
||||
@ -136,7 +136,7 @@ void x509write_csr_set_rsa_key( x509_csr *ctx, rsa_context *rsa );
|
||||
* \param ctx CSR context to use
|
||||
* \param md_ald MD algorithm to use
|
||||
*/
|
||||
void x509write_csr_set_md_alg( x509_csr *ctx, md_type_t md_alg );
|
||||
void x509write_csr_set_md_alg( x509write_csr *ctx, md_type_t md_alg );
|
||||
|
||||
/**
|
||||
* \brief Set the Key Usage Extension flags
|
||||
@ -147,7 +147,7 @@ void x509write_csr_set_md_alg( x509_csr *ctx, md_type_t md_alg );
|
||||
*
|
||||
* \return 0 if successful, or POLARSSL_ERR_X509WRITE_MALLOC_FAILED
|
||||
*/
|
||||
int x509write_csr_set_key_usage( x509_csr *ctx, unsigned char key_usage );
|
||||
int x509write_csr_set_key_usage( x509write_csr *ctx, unsigned char key_usage );
|
||||
|
||||
/**
|
||||
* \brief Set the Netscape Cert Type flags
|
||||
@ -158,7 +158,8 @@ int x509write_csr_set_key_usage( x509_csr *ctx, unsigned char key_usage );
|
||||
*
|
||||
* \return 0 if successful, or POLARSSL_ERR_X509WRITE_MALLOC_FAILED
|
||||
*/
|
||||
int x509write_csr_set_ns_cert_type( x509_csr *ctx, unsigned char ns_cert_type );
|
||||
int x509write_csr_set_ns_cert_type( x509write_csr *ctx,
|
||||
unsigned char ns_cert_type );
|
||||
|
||||
/**
|
||||
* \brief Generic function to add to or replace an extension in the CSR
|
||||
@ -171,7 +172,7 @@ int x509write_csr_set_ns_cert_type( x509_csr *ctx, unsigned char ns_cert_type );
|
||||
*
|
||||
* \return 0 if successful, or a POLARSSL_ERR_X509WRITE_MALLOC_FAILED
|
||||
*/
|
||||
int x509write_csr_set_extension( x509_csr *ctx,
|
||||
int x509write_csr_set_extension( x509write_csr *ctx,
|
||||
const char *oid, size_t oid_len,
|
||||
const unsigned char *val, size_t val_len );
|
||||
|
||||
@ -180,7 +181,7 @@ int x509write_csr_set_extension( x509_csr *ctx,
|
||||
*
|
||||
* \param ctx CSR context to free
|
||||
*/
|
||||
void x509write_csr_free( x509_csr *ctx );
|
||||
void x509write_csr_free( x509write_csr *ctx );
|
||||
|
||||
/**
|
||||
* \brief Initialize a CRT writing context
|
||||
@ -399,7 +400,7 @@ int x509write_key_der( rsa_context *rsa, unsigned char *buf, size_t size );
|
||||
* \return length of data written if successful, or a specific
|
||||
* error code
|
||||
*/
|
||||
int x509write_csr_der( x509_csr *ctx, unsigned char *buf, size_t size );
|
||||
int x509write_csr_der( x509write_csr *ctx, unsigned char *buf, size_t size );
|
||||
|
||||
#if defined(POLARSSL_BASE64_C)
|
||||
/**
|
||||
@ -445,7 +446,7 @@ int x509write_key_pem( rsa_context *rsa, unsigned char *buf, size_t size );
|
||||
*
|
||||
* \return 0 successful, or a specific error code
|
||||
*/
|
||||
int x509write_csr_pem( x509_csr *ctx, unsigned char *buf, size_t size );
|
||||
int x509write_csr_pem( x509write_csr *ctx, unsigned char *buf, size_t size );
|
||||
#endif /* POLARSSL_BASE64_C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -134,30 +134,30 @@ static int x509_write_rsa_pubkey( unsigned char **p, unsigned char *start,
|
||||
return( len );
|
||||
}
|
||||
|
||||
void x509write_csr_init( x509_csr *ctx )
|
||||
void x509write_csr_init( x509write_csr *ctx )
|
||||
{
|
||||
memset( ctx, 0, sizeof(x509_csr) );
|
||||
memset( ctx, 0, sizeof(x509write_csr) );
|
||||
}
|
||||
|
||||
void x509write_csr_free( x509_csr *ctx )
|
||||
void x509write_csr_free( x509write_csr *ctx )
|
||||
{
|
||||
asn1_free_named_data_list( &ctx->subject );
|
||||
asn1_free_named_data_list( &ctx->extensions );
|
||||
|
||||
memset( ctx, 0, sizeof(x509_csr) );
|
||||
memset( ctx, 0, sizeof(x509write_csr) );
|
||||
}
|
||||
|
||||
void x509write_csr_set_md_alg( x509_csr *ctx, md_type_t md_alg )
|
||||
void x509write_csr_set_md_alg( x509write_csr *ctx, md_type_t md_alg )
|
||||
{
|
||||
ctx->md_alg = md_alg;
|
||||
}
|
||||
|
||||
void x509write_csr_set_rsa_key( x509_csr *ctx, rsa_context *rsa )
|
||||
void x509write_csr_set_rsa_key( x509write_csr *ctx, rsa_context *rsa )
|
||||
{
|
||||
ctx->rsa = rsa;
|
||||
}
|
||||
|
||||
int x509write_csr_set_subject_name( x509_csr *ctx, char *subject_name )
|
||||
int x509write_csr_set_subject_name( x509write_csr *ctx, char *subject_name )
|
||||
{
|
||||
return x509write_string_to_names( &ctx->subject, subject_name );
|
||||
}
|
||||
@ -184,7 +184,7 @@ static int x509_set_extension( asn1_named_data **head,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int x509write_csr_set_extension( x509_csr *ctx,
|
||||
int x509write_csr_set_extension( x509write_csr *ctx,
|
||||
const char *oid, size_t oid_len,
|
||||
const unsigned char *val, size_t val_len )
|
||||
{
|
||||
@ -192,7 +192,7 @@ int x509write_csr_set_extension( x509_csr *ctx,
|
||||
0, val, val_len );
|
||||
}
|
||||
|
||||
int x509write_csr_set_key_usage( x509_csr *ctx, unsigned char key_usage )
|
||||
int x509write_csr_set_key_usage( x509write_csr *ctx, unsigned char key_usage )
|
||||
{
|
||||
unsigned char buf[4];
|
||||
unsigned char *c;
|
||||
@ -212,7 +212,8 @@ int x509write_csr_set_key_usage( x509_csr *ctx, unsigned char key_usage )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int x509write_csr_set_ns_cert_type( x509_csr *ctx, unsigned char ns_cert_type )
|
||||
int x509write_csr_set_ns_cert_type( x509write_csr *ctx,
|
||||
unsigned char ns_cert_type )
|
||||
{
|
||||
unsigned char buf[4];
|
||||
unsigned char *c;
|
||||
@ -248,7 +249,7 @@ void x509write_crt_free( x509write_cert *ctx )
|
||||
asn1_free_named_data_list( &ctx->issuer );
|
||||
asn1_free_named_data_list( &ctx->extensions );
|
||||
|
||||
memset( ctx, 0, sizeof(x509_csr) );
|
||||
memset( ctx, 0, sizeof(x509write_csr) );
|
||||
}
|
||||
|
||||
void x509write_crt_set_md_alg( x509write_cert *ctx, md_type_t md_alg )
|
||||
@ -644,7 +645,7 @@ static int x509_write_extensions( unsigned char **p, unsigned char *start,
|
||||
return( len );
|
||||
}
|
||||
|
||||
int x509write_csr_der( x509_csr *ctx, unsigned char *buf, size_t size )
|
||||
int x509write_csr_der( x509write_csr *ctx, unsigned char *buf, size_t size )
|
||||
{
|
||||
int ret;
|
||||
const char *sig_oid;
|
||||
@ -975,7 +976,7 @@ int x509write_key_pem( rsa_context *rsa, unsigned char *buf, size_t size )
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int x509write_csr_pem( x509_csr *ctx, unsigned char *buf, size_t size )
|
||||
int x509write_csr_pem( x509write_csr *ctx, unsigned char *buf, size_t size )
|
||||
{
|
||||
int ret;
|
||||
unsigned char output_buf[4096];
|
||||
|
@ -60,7 +60,7 @@ struct options
|
||||
unsigned char ns_cert_type; /* NS cert type */
|
||||
} opt;
|
||||
|
||||
int write_certificate_request( x509_csr *req, char *output_file )
|
||||
int write_certificate_request( x509write_csr *req, char *output_file )
|
||||
{
|
||||
int ret;
|
||||
FILE *f;
|
||||
@ -130,7 +130,7 @@ int main( int argc, char *argv[] )
|
||||
char buf[1024];
|
||||
int i, j, n;
|
||||
char *p, *q, *r;
|
||||
x509_csr req;
|
||||
x509write_csr req;
|
||||
|
||||
/*
|
||||
* Set to sane values
|
||||
|
@ -16,7 +16,7 @@ void x509_csr_check( char *key_file, int md_type,
|
||||
{
|
||||
rsa_context rsa;
|
||||
pem_context pem;
|
||||
x509_csr req;
|
||||
x509write_csr req;
|
||||
unsigned char *c;
|
||||
unsigned char buf[4000];
|
||||
unsigned char check_buf[4000];
|
||||
|
Loading…
Reference in New Issue
Block a user