2008-11-06 02:39:08 +08:00
|
|
|
/*
|
2021-04-08 20:04:41 +08:00
|
|
|
* Copyright 1999-2021 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
|
|
|
|
2021-03-09 08:52:15 +08:00
|
|
|
const X509V3_EXT_METHOD ossl_v3_ns_ia5_list[8] = {
|
1999-01-24 08:50:01 +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
|
|
|
|
};
|
|
|
|
|
2014-08-15 10:11:08 +08:00
|
|
|
char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5)
|
1999-01-24 08:50:01 +08:00
|
|
|
{
|
|
|
|
char *tmp;
|
2015-05-07 01:43:59 +08:00
|
|
|
|
2021-04-12 11:58:14 +08:00
|
|
|
if (ia5 == NULL || ia5->length <= 0)
|
1999-01-24 08:50:01 +08:00
|
|
|
return NULL;
|
2022-09-29 19:57:34 +08:00
|
|
|
if ((tmp = OPENSSL_malloc(ia5->length + 1)) == NULL)
|
2004-12-05 09:03:15 +08:00
|
|
|
return NULL;
|
1999-01-24 08:50:01 +08:00
|
|
|
memcpy(tmp, ia5->data, ia5->length);
|
|
|
|
tmp[ia5->length] = 0;
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
ASN1_IA5STRING *ia5;
|
2020-04-22 16:45:16 +08:00
|
|
|
if (str == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NULL_ARGUMENT);
|
1999-01-24 08:50:01 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2022-09-29 19:57:34 +08:00
|
|
|
if ((ia5 = ASN1_IA5STRING_new()) == NULL) {
|
|
|
|
ERR_raise(ERR_LIB_X509V3, ERR_R_ASN1_LIB);
|
|
|
|
return NULL;
|
|
|
|
}
|
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;
|
1999-01-24 08:50:01 +08:00
|
|
|
}
|
2000-02-01 10:21:16 +08:00
|
|
|
#ifdef CHARSET_EBCDIC
|
|
|
|
ebcdic2ascii(ia5->data, ia5->data, ia5->length);
|
|
|
|
#endif /* CHARSET_EBCDIC */
|
1999-01-24 08:50:01 +08:00
|
|
|
return ia5;
|
|
|
|
}
|