int result = 0, need_free = 0;
gnutls_datum _data = { data->data, data->size };
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* If the CRL is in PEM format then decode it
*/
if (format == GNUTLS_X509_FMT_PEM) {
int gnutls_x509_crl_get_issuer_dn(gnutls_x509_crl crl, char *buf,
size_t *sizeof_buf)
{
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_parse_dn(crl->crl,
"tbsCertList.issuer.rdnSequence",
buf, sizeof_buf);
const char *oid, int indx,
char *buf, size_t *sizeof_buf)
{
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_parse_dn_oid(crl->crl,
"tbsCertList.issuer.rdnSequence",
oid, indx, buf, sizeof_buf);
int result;
gnutls_datum sa;
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* Read the signature algorithm. Note that parameters are not
* read. They will be read from the issuer's certificate if needed.
*/
opaque version[5];
int len, result;
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
len = sizeof(version);
if ((result =
asn1_read_value(crl->crl, "tbsCertList.version", version,
**/
time_t gnutls_x509_crl_get_this_update(gnutls_x509_crl crl)
{
+ if (crl == NULL) {
+ gnutls_assert();
+ return (time_t)-1;
+ }
+
return _gnutls_x509_get_time(crl->crl,
"tbsCertList.thisUpdate");
}
**/
time_t gnutls_x509_crl_get_next_update(gnutls_x509_crl crl)
{
+ if (crl == NULL) {
+ gnutls_assert();
+ return (time_t)-1;
+ }
+
return _gnutls_x509_get_time(crl->crl,
"tbsCertList.nextUpdate");
}
int count, result;
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
result =
asn1_number_of_elements(crl->crl,
"tbsCertList.revokedCertificates",
char serial_name[64];
char date_name[64];
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
_gnutls_int2str(index + 1, str_index);
_gnutls_str_cpy(serial_name, sizeof(serial_name),
"tbsCertList.revokedCertificates.?");
int start1, end1;
gnutls_datum crl_signed_data;
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* get the issuer of 'crl'
*/
if ((result =
int gnutls_x509_crl_export( gnutls_x509_crl crl,
gnutls_x509_crt_fmt format, unsigned char* output_data, size_t* output_data_size)
{
+ if (crl == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_export_int( crl->crl, format, PEM_CRL, *output_data_size,
output_data, output_data_size);
}
{
int result = 0, need_free = 0;
gnutls_datum _data;
+
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
_data.data = data->data;
_data.size = data->size;
int gnutls_x509_crq_get_dn(gnutls_x509_crq crq, char *buf,
size_t *sizeof_buf)
{
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_parse_dn( crq->crq, "certificationRequestInfo.subject.rdnSequence",
buf, sizeof_buf);
}
int gnutls_x509_crq_get_dn_by_oid(gnutls_x509_crq crq, const char* oid,
int indx, char *buf, size_t *sizeof_buf)
{
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_parse_dn_oid( crq->crq, "certificationRequestInfo.subject.rdnSequence", oid,
indx, buf, sizeof_buf);
}
int gnutls_x509_crq_get_challenge_password(gnutls_x509_crq crq,
char* pass, size_t* sizeof_pass)
{
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return parse_attribute( crq->crq, "certificationRequestInfo.attributes",
"1.2.840.113549.1.9.7", 0, pass, sizeof_pass);
}
int result;
uint8 null = version;
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
result = asn1_write_value( crq->crq, "certificationRequestInfo.version", &null, 1);
if (result != ASN1_SUCCESS) {
gnutls_assert();
{
int result;
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
result = _gnutls_x509_encode_and_copy_PKI_params( crq->crq,
"certificationRequestInfo.subjectPKInfo", key->pk_algorithm,
key->params, key->params_size);
{
int result;
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* Add the attribute.
*/
result = asn1_write_value( crq->crq, "certificationRequestInfo.attributes", "NEW", 1);
gnutls_datum signature;
const char* pk;
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (key->pk_algorithm != GNUTLS_PK_RSA) {
gnutls_assert();
return GNUTLS_E_UNIMPLEMENTED_FEATURE;
int gnutls_x509_crq_export( gnutls_x509_crq crq,
gnutls_x509_crt_fmt format, unsigned char* output_data, size_t* output_data_size)
{
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_export_int( crq->crq, format, PEM_CRQ, *output_data_size,
output_data, output_data_size);
}
{
int result;
+ if (crq==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
result = _gnutls_x509_get_pk_algorithm( crq->crq, "certificationRequestInfo.subjectPKInfo",
bits);
if (result < 0) {
int result = 0, need_free = 0;
gnutls_datum _data = { data->data, data->size };
+ if (pkcs12==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* If the PKCS12 is in PEM format then decode it
*/
if (format == GNUTLS_X509_FMT_PEM) {
int gnutls_pkcs12_export( gnutls_pkcs12 pkcs12,
gnutls_x509_crt_fmt format, unsigned char* output_data, size_t* output_data_size)
{
+ if (pkcs12==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_export_int( pkcs12->pkcs12, format, PEM_PKCS12, *output_data_size,
output_data, output_data_size);
}
char counter[MAX_INT_DIGITS];
gnutls_datum tmp = {NULL, 0};
+ if (pkcs12==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* Step 1. decode the data.
*/
result = _decode_pkcs12_auth_safe( pkcs12->pkcs12, &c2, NULL);
int enc = 0, dum = 1;
char null;
+ if (pkcs12==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* Step 1. Check if the pkcs12 structure is empty. In that
* case generate an empty PFX.
*/
gnutls_datum tmp = {NULL, 0};
opaque sha_mac[20];
+ if (pkcs12==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* Generate the salt.
*/
_gnutls_get_random(salt, sizeof(salt), GNUTLS_WEAK_RANDOM);
opaque sha_mac[20];
opaque sha_mac_orig[20];
+ if (pkcs12==NULL || pass == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* read the iterations
*/
**/
gnutls_pkcs12_bag_type gnutls_pkcs12_bag_get_type(gnutls_pkcs12_bag bag, int indx)
{
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (indx >= bag->bag_elements)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
return bag->element[indx].type;
**/
int gnutls_pkcs12_bag_get_count(gnutls_pkcs12_bag bag)
{
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return bag->bag_elements;
}
**/
int gnutls_pkcs12_bag_get_data(gnutls_pkcs12_bag bag, int indx, gnutls_const_datum * data)
{
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (indx >= bag->bag_elements)
return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
const gnutls_datum* data)
{
int ret;
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
if (bag->bag_elements == MAX_BAG_ELEMENTS-1) {
gnutls_assert();
int ret;
gnutls_datum data;
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
ret = _gnutls_x509_der_encode( crt->cert, "", &data, 0);
if (ret < 0) {
gnutls_assert();
int ret;
gnutls_datum data;
+
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
ret = _gnutls_x509_der_encode( crl->crl, "", &data, 0);
if (ret < 0) {
gnutls_assert();
{
int ret;
+
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (indx > bag->bag_elements-1) {
gnutls_assert();
return GNUTLS_E_INVALID_REQUEST;
int gnutls_pkcs12_bag_get_key_id(gnutls_pkcs12_bag bag, int indx,
gnutls_datum* id)
{
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
if (indx > bag->bag_elements-1) {
gnutls_assert();
int gnutls_pkcs12_bag_get_friendly_name(gnutls_pkcs12_bag bag, int indx,
char **name)
{
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (indx > bag->bag_elements-1) {
gnutls_assert();
return GNUTLS_E_INVALID_REQUEST;
int gnutls_pkcs12_bag_set_friendly_name(gnutls_pkcs12_bag bag, int indx,
const char* name)
{
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (indx > bag->bag_elements-1) {
gnutls_assert();
return GNUTLS_E_INVALID_REQUEST;
{
int ret;
gnutls_datum dec;
+
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
if (bag->element[0].type != GNUTLS_BAG_ENCRYPTED) {
gnutls_assert();
gnutls_datum enc = {NULL, 0};
schema_id id;
+ if (bag == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (bag->element[0].type == GNUTLS_BAG_ENCRYPTED) {
gnutls_assert();
return GNUTLS_E_INVALID_REQUEST;
{
int result = 0, need_free = 0;
gnutls_datum _data;
+
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
_data.data = data->data;
_data.size = data->size;
int i = 0, ret;
size_t siz = 0;
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
siz = m->size;
if (_gnutls_mpi_scan(&key->params[0], m->data, &siz)) {
gnutls_assert();
**/
int gnutls_x509_privkey_get_pk_algorithm( gnutls_x509_privkey key)
{
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return key->pk_algorithm;
}
gnutls_x509_crt_fmt format, unsigned char* output_data, size_t* output_data_size)
{
char * msg;
+
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
if (key->pk_algorithm == GNUTLS_PK_RSA)
msg = PEM_KEY_RSA;
{
size_t siz;
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
siz = 0;
_gnutls_mpi_print(NULL, &siz, key->params[0]);
{
int ret;
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
switch( algo) {
case GNUTLS_PK_DSA:
return GNUTLS_E_UNIMPLEMENTED_FEATURE;
GNUTLS_HASH_HANDLE hd;
gnutls_datum der = { NULL, 0 };
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (*output_data_size < 20) {
gnutls_assert();
+ *output_data_size = 20;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
gnutls_datum tmp;
schema_id schema;
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* Get the private key info
* tmp holds the DER encoding.
*/
gnutls_datum _data;
int encrypted;
+ if (key == NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
_data.data = data->data;
_data.size = data->size;
int result = 0, need_free = 0;
gnutls_datum _data;
opaque *signature = NULL;
+
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
_data.data = data->data;
_data.size = data->size;
int gnutls_x509_crt_get_issuer_dn(gnutls_x509_crt cert, char *buf,
size_t *sizeof_buf)
{
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_parse_dn( cert->cert, "tbsCertificate.issuer.rdnSequence",
buf, sizeof_buf);
}
int gnutls_x509_crt_get_issuer_dn_by_oid(gnutls_x509_crt cert, const char* oid,
int indx, char *buf, size_t *sizeof_buf)
{
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_parse_dn_oid( cert->cert, "tbsCertificate.issuer.rdnSequence", oid,
indx, buf, sizeof_buf);
}
int gnutls_x509_crt_get_dn(gnutls_x509_crt cert, char *buf,
size_t *sizeof_buf)
{
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_parse_dn( cert->cert, "tbsCertificate.subject.rdnSequence",
buf, sizeof_buf);
}
int gnutls_x509_crt_get_dn_by_oid(gnutls_x509_crt cert, const char* oid,
int indx, char *buf, size_t *sizeof_buf)
{
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_parse_dn_oid( cert->cert, "tbsCertificate.subject.rdnSequence", oid,
indx, buf, sizeof_buf);
}
int result;
gnutls_datum sa;
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
/* Read the signature algorithm. Note that parameters are not
* read. They will be read from the issuer's certificate if needed.
*/
{
opaque version[5];
int len, result;
-
+
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
len = sizeof(version);
if ((result = asn1_read_value(cert->cert, "tbsCertificate.version", version, &len)) !=
ASN1_SUCCESS) {
**/
time_t gnutls_x509_crt_get_activation_time(gnutls_x509_crt cert)
{
+ if (cert==NULL) {
+ gnutls_assert();
+ return (time_t)-1;
+ }
+
return _gnutls_x509_get_time( cert->cert, "tbsCertificate.validity.notBefore");
}
**/
time_t gnutls_x509_crt_get_expiration_time(gnutls_x509_crt cert)
{
+ if (cert==NULL) {
+ gnutls_assert();
+ return (time_t)-1;
+ }
+
return _gnutls_x509_get_time( cert->cert, "tbsCertificate.validity.notAfter");
}
{
int ret;
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if ((ret = asn1_read_value(cert->cert, "tbsCertificate.serialNumber", result, result_size)) < 0) {
gnutls_assert();
return _gnutls_asn2err(ret);
{
int result;
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
result = _gnutls_x509_get_pk_algorithm( cert->cert, "tbsCertificate.subjectPublicKeyInfo",
bits);
char num[MAX_INT_DIGITS];
gnutls_x509_subject_alt_name type;
- memset(ret, 0, *ret_size);
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
+ if (ret) memset(ret, 0, *ret_size);
+ else *ret_size = 0;
if ((result =
_gnutls_x509_crt_get_extension(cert, "2.5.29.17", 0, &dnsname, critical)) < 0) {
_gnutls_str_cat( nptr, sizeof(nptr), ".");
_gnutls_str_cat( nptr, sizeof(nptr), ext_data);
- len = sizeof(ext_data);
-
+ len = *ret_size;
result =
- asn1_read_value(c2, nptr, ret, ret_size);
+ asn1_read_value(c2, nptr, ret, &len);
asn1_delete_structure(&c2);
-
+ *ret_size = len;
+
if (result==ASN1_MEM_ERROR)
return GNUTLS_E_SHORT_MEMORY_BUFFER;
gnutls_datum basicConstraints;
int ca;
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if ((result =
_gnutls_x509_crt_get_extension(cert, "2.5.29.19", 0, &basicConstraints, critical)) < 0) {
gnutls_assert();
gnutls_datum keyUsage;
uint16 _usage;
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if ((result =
_gnutls_x509_crt_get_extension(cert, "2.5.29.15", 0, &keyUsage, critical)) < 0) {
return result;
int result;
gnutls_datum output;
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if ((result =
_gnutls_x509_crt_get_extension(cert, oid, indx, &output, critical)) < 0) {
gnutls_assert();
int gnutls_x509_crt_export( gnutls_x509_crt cert,
gnutls_x509_crt_fmt format, unsigned char* output_data, size_t* output_data_size)
{
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
return _gnutls_x509_export_int( cert->cert, format, "CERTIFICATE", *output_data_size,
output_data, output_data_size);
}
gnutls_datum der = { NULL, 0 };
GNUTLS_HASH_HANDLE hd;
+ if (crt==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
if (*output_data_size < 20) {
gnutls_assert();
+ *output_data_size = 20;
return GNUTLS_E_SHORT_MEMORY_BUFFER;
}
int ncerts, ret, i, j;
gnutls_datum dn1, dn2;
+ if (cert==NULL) {
+ gnutls_assert();
+ return GNUTLS_E_INVALID_REQUEST;
+ }
+
for (j = 0; j < crl_list_length; j++) { /* do for all the crls */
/* Step 1. check if issuer's DN match