#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/asn1.h>
#include <openssl/conf.h>
#include <openssl/x509v3.h>
#include "ext_dat.h"
const X509V3_EXT_METHOD ossl_v3_utf8_list[1] = {
EXT_UTF8STRING(NID_subjectSignTool),
};
char *i2s_ASN1_UTF8STRING(X509V3_EXT_METHOD *method,
ASN1_UTF8STRING *utf8)
{
char *tmp;
if (utf8 == NULL || utf8->length == 0) {
ERR_raise(ERR_LIB_X509V3, ERR_R_PASSED_NULL_PARAMETER);
return NULL;
}
if ((tmp = OPENSSL_malloc(utf8->length + 1)) == NULL)
return NULL;
memcpy(tmp, utf8->data, utf8->length);
tmp[utf8->length] = 0;
return tmp;
}
ASN1_UTF8STRING *s2i_ASN1_UTF8STRING(X509V3_EXT_METHOD *method,
X509V3_CTX *ctx, const char *str)
{
ASN1_UTF8STRING *utf8;
if (str == NULL) {
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NULL_ARGUMENT);
return NULL;
}
if ((utf8 = ASN1_UTF8STRING_new()) == NULL) {
ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
return NULL;
}
if (!ASN1_STRING_set((ASN1_STRING *)utf8, str, strlen(str))) {
ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
ASN1_UTF8STRING_free(utf8);
return NULL;
}
#ifdef CHARSET_EBCDIC
ebcdic2ascii(utf8->data, utf8->data, utf8->length);
#endif
return utf8;
}