2015-01-22 03:40:55 +00:00
|
|
|
/*
|
2016-05-17 18:51:26 +00:00
|
|
|
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
1999-01-24 00:50:01 +00:00
|
|
|
*
|
2016-05-17 18:51:26 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1999-01-24 00:50:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-05-14 14:56:48 +00:00
|
|
|
#include "internal/cryptlib.h"
|
1999-04-23 22:13:45 +00:00
|
|
|
#include <openssl/asn1.h>
|
|
|
|
#include <openssl/conf.h>
|
|
|
|
#include <openssl/x509v3.h>
|
2015-09-05 12:32:58 +00:00
|
|
|
#include "ext_dat.h"
|
1999-01-24 00:50:01 +00:00
|
|
|
|
2016-06-05 12:13:33 +00:00
|
|
|
const X509V3_EXT_METHOD v3_ns_ia5_list[8] = {
|
2015-01-22 03:40:55 +00:00
|
|
|
EXT_IA5STRING(NID_netscape_base_url),
|
|
|
|
EXT_IA5STRING(NID_netscape_revocation_url),
|
|
|
|
EXT_IA5STRING(NID_netscape_ca_revocation_url),
|
|
|
|
EXT_IA5STRING(NID_netscape_renewal_url),
|
|
|
|
EXT_IA5STRING(NID_netscape_ca_policy_url),
|
|
|
|
EXT_IA5STRING(NID_netscape_ssl_server_name),
|
|
|
|
EXT_IA5STRING(NID_netscape_comment),
|
|
|
|
EXT_END
|
1999-01-24 00:50:01 +00:00
|
|
|
};
|
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5)
|
1999-01-24 00:50:01 +00:00
|
|
|
{
|
2015-01-22 03:40:55 +00:00
|
|
|
char *tmp;
|
2015-05-06 17:43:59 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
if (!ia5 || !ia5->length)
|
|
|
|
return NULL;
|
2015-05-06 17:43:59 +00:00
|
|
|
if ((tmp = OPENSSL_malloc(ia5->length + 1)) == NULL) {
|
2015-01-22 03:40:55 +00:00
|
|
|
X509V3err(X509V3_F_I2S_ASN1_IA5STRING, ERR_R_MALLOC_FAILURE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
memcpy(tmp, ia5->data, ia5->length);
|
|
|
|
tmp[ia5->length] = 0;
|
|
|
|
return tmp;
|
1999-01-24 00:50:01 +00:00
|
|
|
}
|
|
|
|
|
2014-08-15 02:11:08 +00:00
|
|
|
ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
|
2016-05-14 21:03:22 +00:00
|
|
|
X509V3_CTX *ctx, const char *str)
|
1999-01-24 00:50:01 +00:00
|
|
|
{
|
2015-01-22 03:40:55 +00:00
|
|
|
ASN1_IA5STRING *ia5;
|
|
|
|
if (!str) {
|
|
|
|
X509V3err(X509V3_F_S2I_ASN1_IA5STRING,
|
|
|
|
X509V3_R_INVALID_NULL_ARGUMENT);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-05-06 17:43:59 +00:00
|
|
|
if ((ia5 = ASN1_IA5STRING_new()) == NULL)
|
2015-01-22 03:40:55 +00:00
|
|
|
goto err;
|
2016-05-14 21:03:22 +00:00
|
|
|
if (!ASN1_STRING_set((ASN1_STRING *)ia5, str, strlen(str))) {
|
2015-03-14 04:16:42 +00:00
|
|
|
ASN1_IA5STRING_free(ia5);
|
2016-05-14 21:03:22 +00:00
|
|
|
return NULL;
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
2000-02-01 02:21:16 +00:00
|
|
|
#ifdef CHARSET_EBCDIC
|
2015-01-22 03:40:55 +00:00
|
|
|
ebcdic2ascii(ia5->data, ia5->data, ia5->length);
|
|
|
|
#endif /* CHARSET_EBCDIC */
|
|
|
|
return ia5;
|
|
|
|
err:
|
|
|
|
X509V3err(X509V3_F_S2I_ASN1_IA5STRING, ERR_R_MALLOC_FAILURE);
|
|
|
|
return NULL;
|
1999-01-24 00:50:01 +00:00
|
|
|
}
|