/** * gnutls_x509_crl_get_issuer_dn: * @crl: should contain a gnutls_x509_crl_t structure * @buf: a pointer to a structure to hold the peer's name (may be null) * @sizeof_buf: initially holds the size of @buf * * This function will copy the name of the CRL issuer in the provided * buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as * described in RFC4514. The output string will be ASCII or UTF-8 * encoded, depending on the certificate data. * * If buf is %NULL then only the size will be filled. * * Returns: %GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is * not long enough, and in that case the sizeof_buf will be updated * with the required size, and 0 on success. * **/ int gnutls_x509_crl_get_issuer_dn(const gnutls_x509_crl_t 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); }
/** * gnutls_x509_crq_get_dn - This function returns the Certificate request subject's distinguished name * @crq: should contain a gnutls_x509_crq_t structure * @buf: a pointer to a structure to hold the name (may be null) * @sizeof_buf: initially holds the size of @buf * * This function will copy the name of the Certificate request * subject in the provided buffer. The name will be in the form * "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output string * will be ASCII or UTF-8 encoded, depending on the certificate data. * * If @buf is null then only the size will be filled. * * Returns GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not * long enough, and in that case the *sizeof_buf will be updated with * the required size. On success 0 is returned. * **/ int gnutls_x509_crq_get_dn (gnutls_x509_crq_t 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); }
/** * gnutls_x509_rdn_get - This function parses an RDN sequence and returns a string * @idn: should contain a DER encoded RDN sequence * @buf: a pointer to a structure to hold the peer's name * @sizeof_buf: holds the size of @buf * * This function will return the name of the given RDN sequence. The * name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in * RFC2253. * * If the provided buffer is not long enough, returns * GNUTLS_E_SHORT_MEMORY_BUFFER and *sizeof_buf will be updated. On * success 0 is returned. * **/ int gnutls_x509_rdn_get (const gnutls_datum_t * idn, char *buf, size_t * sizeof_buf) { int result; ASN1_TYPE dn = ASN1_TYPE_EMPTY; if (sizeof_buf == 0) { gnutls_assert (); return GNUTLS_E_INVALID_REQUEST; } if (buf) buf[0] = 0; if ((result = asn1_create_element (_gnutls_get_pkix (), "PKIX1.Name", &dn)) != ASN1_SUCCESS) { gnutls_assert (); return _gnutls_asn2err (result); } result = asn1_der_decoding (&dn, idn->data, idn->size, NULL); if (result != ASN1_SUCCESS) { /* couldn't decode DER */ gnutls_assert (); asn1_delete_structure (&dn); return _gnutls_asn2err (result); } result = _gnutls_x509_parse_dn (dn, "rdnSequence", buf, sizeof_buf); asn1_delete_structure (&dn); return result; }