28 #if defined(POLARSSL_X509_WRITE_C)
115 int x509_write_name(
unsigned char **p,
unsigned char *start,
char *oid,
119 size_t string_len = 0;
137 len = oid_len + string_len;
150 static void x509_hash(
const unsigned char *in,
size_t len,
int alg,
155 #if defined(POLARSSL_MD2_C)
158 #if defined(POLARSSL_MD4_C)
161 #if defined(POLARSSL_MD5_C)
164 #if defined(POLARSSL_SHA1_C)
167 #if defined(POLARSSL_SHA2_C)
171 #if defined(POLARSSL_SHA4_C)
176 memset( out,
'\xFF', 64 );
181 int x509_write_sig(
unsigned char **p,
unsigned char *start,
char *oid,
182 unsigned char *sig,
size_t size )
187 if( *p - start < (
int) size + 1 )
192 memcpy( *p, sig, len );
212 unsigned char *c, *c2;
213 unsigned char hash[64];
215 unsigned char tmp_buf[2048];
216 size_t sub_len = 0, pub_len = 0, sig_len = 0;
220 c = tmp_buf + 2048 - 1;
231 if( c - tmp_buf < 1 )
262 x509_hash( c, len, hash_id, hash );
269 sig_oid[8] = hash_id;
273 ASN1_CHK_ADD( sig_len, x509_write_sig( &c2, buf, sig_oid, sig, rsa->
len ) );
276 memcpy( c2, c, len );
int x509_write_pubkey_der(unsigned char *buf, size_t size, rsa_context *rsa)
#define POLARSSL_MPI_MAX_SIZE
Maximum number of bytes for usable MPIs.
void sha1(const unsigned char *input, size_t ilen, unsigned char output[20])
Output = SHA-1( input buffer )
#define POLARSSL_ERR_ASN1_BUF_TOO_SMALL
Buffer too small when writing ASN.1 data structure.
int rsa_pkcs1_sign(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, int hash_id, unsigned int hashlen, const unsigned char *hash, unsigned char *sig)
Generic wrapper to perform a PKCS#1 signature using the mode from the context.
Configuration options (set of defines)
void md2(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD2( input buffer )
struct _x509_req_name * next
void md4(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD4( input buffer )
#define OID_SIZE(x)
Returns the size of the binary string, without the trailing \0.
int asn1_write_len(unsigned char **p, unsigned char *start, size_t len)
SHA-384 and SHA-512 cryptographic hash function.
SHA-224 and SHA-256 cryptographic hash function.
int asn1_write_algorithm_identifier(unsigned char **p, unsigned char *start, char *algorithm_oid)
int x509_write_cert_req(unsigned char *buf, size_t size, rsa_context *rsa, x509_req_name *req_name, int hash_id)
X.509 certificate and private key decoding.
#define ASN1_CONTEXT_SPECIFIC
int asn1_write_mpi(unsigned char **p, unsigned char *start, mpi *X)
int asn1_write_int(unsigned char **p, unsigned char *start, int val)
X509 buffer writing functionality.
int x509_write_key_der(unsigned char *buf, size_t size, rsa_context *rsa)
#define ASN1_CHK_ADD(g, f)
void sha4(const unsigned char *input, size_t ilen, unsigned char output[64], int is384)
Output = SHA-512( input buffer )
SHA-1 cryptographic hash function.
int asn1_write_printable_string(unsigned char **p, unsigned char *start, char *text)
int asn1_write_oid(unsigned char **p, unsigned char *start, char *oid)
ASN.1 buffer writing functionality.
void sha2(const unsigned char *input, size_t ilen, unsigned char output[32], int is224)
Output = SHA-256( input buffer )
int asn1_write_ia5_string(unsigned char **p, unsigned char *start, char *text)
int asn1_write_tag(unsigned char **p, unsigned char *start, unsigned char tag)
MD4 message digest algorithm (hash function)
MD5 message digest algorithm (hash function)
void md5(const unsigned char *input, size_t ilen, unsigned char output[16])
Output = MD5( input buffer )