2
0

v3_ia5.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <stdio.h>
  10. #include "internal/cryptlib.h"
  11. #include <openssl/asn1.h>
  12. #include <openssl/conf.h>
  13. #include <openssl/x509v3.h>
  14. #include "ext_dat.h"
  15. const X509V3_EXT_METHOD v3_ns_ia5_list[8] = {
  16. EXT_IA5STRING(NID_netscape_base_url),
  17. EXT_IA5STRING(NID_netscape_revocation_url),
  18. EXT_IA5STRING(NID_netscape_ca_revocation_url),
  19. EXT_IA5STRING(NID_netscape_renewal_url),
  20. EXT_IA5STRING(NID_netscape_ca_policy_url),
  21. EXT_IA5STRING(NID_netscape_ssl_server_name),
  22. EXT_IA5STRING(NID_netscape_comment),
  23. EXT_END
  24. };
  25. char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5)
  26. {
  27. char *tmp;
  28. if (ia5 == NULL || ia5->length == 0)
  29. return NULL;
  30. if ((tmp = OPENSSL_malloc(ia5->length + 1)) == NULL) {
  31. X509V3err(X509V3_F_I2S_ASN1_IA5STRING, ERR_R_MALLOC_FAILURE);
  32. return NULL;
  33. }
  34. memcpy(tmp, ia5->data, ia5->length);
  35. tmp[ia5->length] = 0;
  36. return tmp;
  37. }
  38. ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
  39. X509V3_CTX *ctx, const char *str)
  40. {
  41. ASN1_IA5STRING *ia5;
  42. if (str == NULL) {
  43. X509V3err(X509V3_F_S2I_ASN1_IA5STRING,
  44. X509V3_R_INVALID_NULL_ARGUMENT);
  45. return NULL;
  46. }
  47. if ((ia5 = ASN1_IA5STRING_new()) == NULL)
  48. goto err;
  49. if (!ASN1_STRING_set((ASN1_STRING *)ia5, str, strlen(str))) {
  50. ASN1_IA5STRING_free(ia5);
  51. return NULL;
  52. }
  53. #ifdef CHARSET_EBCDIC
  54. ebcdic2ascii(ia5->data, ia5->data, ia5->length);
  55. #endif /* CHARSET_EBCDIC */
  56. return ia5;
  57. err:
  58. X509V3err(X509V3_F_S2I_ASN1_IA5STRING, ERR_R_MALLOC_FAILURE);
  59. return NULL;
  60. }