2015-01-22 11:40:55 +08:00
|
|
|
/*
|
2016-05-18 02:51:26 +08:00
|
|
|
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
1999-01-24 08:50:01 +08:00
|
|
|
*
|
2018-12-06 21:00:54 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:51:26 +08:00
|
|
|
* 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 08:50:01 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2015-05-14 22:56:48 +08:00
|
|
|
#include "internal/cryptlib.h"
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/asn1.h>
|
|
|
|
#include <openssl/conf.h>
|
|
|
|
#include <openssl/x509v3.h>
|
2015-09-05 20:32:58 +08:00
|
|
|
#include "ext_dat.h"
|
1999-01-24 08:50:01 +08:00
|
|
|
|
2016-06-05 20:13:33 +08:00
|
|
|
const X509V3_EXT_METHOD v3_ns_ia5_list[8] = {
|
2015-01-22 11:40:55 +08: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 08:50:01 +08:00
|
|
|
};
|
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5)
|
1999-01-24 08:50:01 +08:00
|
|
|
{
|
2015-01-22 11:40:55 +08:00
|
|
|
char *tmp;
|
2015-05-07 01:43:59 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
if (!ia5 || !ia5->length)
|
|
|
|
return NULL;
|
2015-05-07 01:43:59 +08:00
|
|
|
if ((tmp = OPENSSL_malloc(ia5->length + 1)) == NULL) {
|
2015-01-22 11:40:55 +08: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 08:50:01 +08:00
|
|
|
}
|
|
|
|
|
2014-08-15 10:11:08 +08:00
|
|
|
ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
|
2016-05-15 05:03:22 +08:00
|
|
|
X509V3_CTX *ctx, const char *str)
|
1999-01-24 08:50:01 +08:00
|
|
|
{
|
2015-01-22 11:40:55 +08:00
|
|
|
ASN1_IA5STRING *ia5;
|
|
|
|
if (!str) {
|
|
|
|
X509V3err(X509V3_F_S2I_ASN1_IA5STRING,
|
|
|
|
X509V3_R_INVALID_NULL_ARGUMENT);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-05-07 01:43:59 +08:00
|
|
|
if ((ia5 = ASN1_IA5STRING_new()) == NULL)
|
2015-01-22 11:40:55 +08:00
|
|
|
goto err;
|
2016-05-15 05:03:22 +08:00
|
|
|
if (!ASN1_STRING_set((ASN1_STRING *)ia5, str, strlen(str))) {
|
2015-03-14 12:16:42 +08:00
|
|
|
ASN1_IA5STRING_free(ia5);
|
2016-05-15 05:03:22 +08:00
|
|
|
return NULL;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
2000-02-01 10:21:16 +08:00
|
|
|
#ifdef CHARSET_EBCDIC
|
2015-01-22 11:40:55 +08: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 08:50:01 +08:00
|
|
|
}
|