Coverage Report

Created: 2026-06-28 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boringssl/crypto/x509/v3_ia5.cc
Line
Count
Source
1
// Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <stdio.h>
16
#include <string.h>
17
18
#include <openssl/asn1.h>
19
#include <openssl/conf.h>
20
#include <openssl/err.h>
21
#include <openssl/mem.h>
22
#include <openssl/obj.h>
23
#include <openssl/x509.h>
24
25
#include "../internal.h"
26
#include "internal.h"
27
28
29
using namespace bssl;
30
31
402
static char *i2s_ASN1_IA5STRING(const X509V3_EXT_METHOD *method, void *ext) {
32
402
  const ASN1_IA5STRING *ia5 = reinterpret_cast<const ASN1_IA5STRING *>(ext);
33
402
  char *tmp;
34
402
  if (!ia5 || !ia5->length) {
35
14
    return nullptr;
36
14
  }
37
388
  if (!(tmp = reinterpret_cast<char *>(OPENSSL_malloc(ia5->length + 1)))) {
38
0
    return nullptr;
39
0
  }
40
388
  OPENSSL_memcpy(tmp, ia5->data, ia5->length);
41
388
  tmp[ia5->length] = 0;
42
388
  return tmp;
43
388
}
44
45
static void *s2i_ASN1_IA5STRING(const X509V3_EXT_METHOD *method,
46
0
                                const X509V3_CTX *ctx, const char *str) {
47
0
  ASN1_IA5STRING *ia5;
48
0
  if (!str) {
49
0
    OPENSSL_PUT_ERROR(X509V3, X509V3_R_INVALID_NULL_ARGUMENT);
50
0
    return nullptr;
51
0
  }
52
0
  if (!(ia5 = ASN1_IA5STRING_new())) {
53
0
    goto err;
54
0
  }
55
0
  if (!ASN1_STRING_set(ia5, str, strlen(str))) {
56
0
    ASN1_IA5STRING_free(ia5);
57
0
    goto err;
58
0
  }
59
0
  return ia5;
60
0
err:
61
0
  return nullptr;
62
0
}
63
64
#define EXT_IA5STRING(nid)                                                 \
65
  {                                                                        \
66
    nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), 0, 0, 0, 0, i2s_ASN1_IA5STRING, \
67
        s2i_ASN1_IA5STRING, 0, 0, 0, 0, nullptr                            \
68
  }
69
70
const X509V3_EXT_METHOD bssl::v3_netscape_base_url =
71
    EXT_IA5STRING(NID_netscape_base_url);
72
const X509V3_EXT_METHOD bssl::v3_netscape_revocation_url =
73
    EXT_IA5STRING(NID_netscape_revocation_url);
74
const X509V3_EXT_METHOD bssl::v3_netscape_ca_revocation_url =
75
    EXT_IA5STRING(NID_netscape_ca_revocation_url);
76
const X509V3_EXT_METHOD bssl::v3_netscape_renewal_url =
77
    EXT_IA5STRING(NID_netscape_renewal_url);
78
const X509V3_EXT_METHOD bssl::v3_netscape_ca_policy_url =
79
    EXT_IA5STRING(NID_netscape_ca_policy_url);
80
const X509V3_EXT_METHOD bssl::v3_netscape_ssl_server_name =
81
    EXT_IA5STRING(NID_netscape_ssl_server_name);
82
const X509V3_EXT_METHOD bssl::v3_netscape_comment =
83
    EXT_IA5STRING(NID_netscape_comment);