| 1 |
|
| #define PERL_NO_GET_CONTEXT |
| 2 |
|
| #include "EXTERN.h" |
| 3 |
|
| #include "perl.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| |
| 6 |
|
| #include <openssl/evp.h> |
| 7 |
|
| #include <openssl/x509.h> |
| 8 |
|
| #include <openssl/x509v3.h> |
| 9 |
|
| #include <openssl/pem.h> |
| 10 |
|
| #include <openssl/err.h> |
| 11 |
|
| #include <openssl/bn.h> |
| 12 |
|
| #include <openssl/rsa.h> |
| 13 |
|
| #include <openssl/ec.h> |
| 14 |
|
| #include <openssl/ecdsa.h> |
| 15 |
|
| #include <openssl/obj_mac.h> |
| 16 |
|
| #include <openssl/rand.h> |
| 17 |
|
| #include <string.h> |
| 18 |
|
| |
| 19 |
|
| #if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 20 |
|
| #include <openssl/param_build.h> |
| 21 |
|
| #include <openssl/core_names.h> |
| 22 |
|
| #endif |
| 23 |
|
| |
| 24 |
4 |
| static int generate_mock_cert(pTHX_ char **cert_pem_out, char **key_pem_out) { |
| 25 |
4 |
| EVP_PKEY *pkey = NULL; |
| 26 |
4 |
| EVP_PKEY_CTX *pctx = NULL; |
| 27 |
4 |
| X509 *x509 = NULL; |
| 28 |
4 |
| X509_NAME *name = NULL; |
| 29 |
4 |
| BIO *cert_bio = NULL; |
| 30 |
4 |
| BIO *key_bio = NULL; |
| 31 |
4 |
| char *cert_pem = NULL; |
| 32 |
4 |
| char *key_pem = NULL; |
| 33 |
4 |
| long cert_len = 0; |
| 34 |
4 |
| long key_len = 0; |
| 35 |
4 |
| int ret = 0; |
| 36 |
|
| |
| 37 |
4 |
| pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_RSA, NULL); |
| 38 |
4 |
▶ | if (!pctx) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pctx) goto cleanup; |
0 |
4 |
4 |
|
| 39 |
4 |
▶ | if (EVP_PKEY_keygen_init(pctx) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (EVP_PKEY_keygen_init(pctx) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 40 |
4 |
▶ | if (EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (EVP_PKEY_CTX_set_rsa_keygen_bits(pctx, 2048) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 41 |
4 |
▶ | if (EVP_PKEY_keygen(pctx, &pkey) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (EVP_PKEY_keygen(pctx, &pkey) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 42 |
|
| |
| 43 |
4 |
| x509 = X509_new(); |
| 44 |
4 |
▶ | if (!x509) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!x509) goto cleanup; |
0 |
4 |
4 |
|
| 45 |
|
| |
| 46 |
4 |
▶ | if (X509_set_version(x509, 2) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (X509_set_version(x509, 2) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 47 |
|
| |
| 48 |
4 |
▶ | if (ASN1_INTEGER_set(X509_get_serialNumber(x509), 1) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (ASN1_INTEGER_set(X509_get_serialNumber(x509), 1) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 49 |
|
| |
| 50 |
4 |
▶ | if (!X509_gmtime_adj(X509_get_notBefore(x509), 0)) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!X509_gmtime_adj(X509_get_notBefore(x509), 0)) goto cleanup; |
0 |
4 |
4 |
|
| 51 |
4 |
▶ | if (!X509_gmtime_adj(X509_get_notAfter(x509), 31536000L)) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!X509_gmtime_adj(X509_get_notAfter(x509), 31536000L)) goto cleanup; |
0 |
4 |
4 |
|
| 52 |
|
| |
| 53 |
4 |
▶ | if (X509_set_pubkey(x509, pkey) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (X509_set_pubkey(x509, pkey) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 54 |
|
| |
| 55 |
4 |
| name = X509_get_subject_name(x509); |
| 56 |
4 |
▶ | if (!name) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!name) goto cleanup; |
0 |
4 |
4 |
|
| 57 |
4 |
▶ | if (X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char*)"BE", -1, -1, 0) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (X509_NAME_add_entry_by_txt(name, "C", MBSTRING_ASC, (unsigned char*)"BE", -1, -1, 0) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 58 |
4 |
▶ | if (X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, (unsigned char*)"Test", -1, -1, 0) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (X509_NAME_add_entry_by_txt(name, "O", MBSTRING_ASC, (unsigned char*)"Test", -1, -1, 0) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 59 |
4 |
▶ | if (X509_NAME_add_entry_by_txt(name, "OU", MBSTRING_ASC, (unsigned char*)"Test", -1, -1, 0) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (X509_NAME_add_entry_by_txt(name, "OU", MBSTRING_ASC, (unsigned char*)"Test", -1, -1, 0) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 60 |
4 |
▶ | if (X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char*)"Test", -1, -1, 0) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char*)"Test", -1, -1, 0) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 61 |
4 |
▶ | if (X509_set_issuer_name(x509, name) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (X509_set_issuer_name(x509, name) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 62 |
|
| |
| 63 |
4 |
▶ | if (X509_sign(x509, pkey, EVP_sha256()) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (X509_sign(x509, pkey, EVP_sha256()) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 64 |
|
| |
| 65 |
4 |
| key_bio = BIO_new(BIO_s_mem()); |
| 66 |
4 |
▶ | if (!key_bio) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!key_bio) goto cleanup; |
0 |
4 |
4 |
|
| 67 |
4 |
▶ | if (PEM_write_bio_PrivateKey(key_bio, pkey, NULL, NULL, 0, NULL, NULL) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (PEM_write_bio_PrivateKey(key_bio, pkey, NULL, NULL, 0, NULL, NULL) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 68 |
4 |
| key_len = BIO_get_mem_data(key_bio, &key_pem); |
| 69 |
|
| |
| 70 |
4 |
| cert_bio = BIO_new(BIO_s_mem()); |
| 71 |
4 |
▶ | if (!cert_bio) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!cert_bio) goto cleanup; |
0 |
4 |
4 |
|
| 72 |
4 |
▶ | if (PEM_write_bio_X509(cert_bio, x509) <= 0) goto cleanup; |
Branch: 1 branch
| Branch | True | False | Total |
| if (PEM_write_bio_X509(cert_bio, x509) <= 0) goto cleanup; |
0 |
4 |
4 |
|
| 73 |
4 |
| cert_len = BIO_get_mem_data(cert_bio, &cert_pem); |
| 74 |
|
| |
| 75 |
4 |
| Newx(*cert_pem_out, cert_len + 1, char); |
| 76 |
4 |
| memcpy(*cert_pem_out, cert_pem, cert_len); |
| 77 |
4 |
| (*cert_pem_out)[cert_len] = '\0'; |
| 78 |
|
| |
| 79 |
4 |
| Newx(*key_pem_out, key_len + 1, char); |
| 80 |
4 |
| memcpy(*key_pem_out, key_pem, key_len); |
| 81 |
4 |
| (*key_pem_out)[key_len] = '\0'; |
| 82 |
4 |
| memcpy(*key_pem_out, key_pem, key_len); |
| 83 |
4 |
| (*key_pem_out)[key_len] = '\0'; |
| 84 |
|
| |
| 85 |
4 |
| ret = 1; |
| 86 |
|
| |
| 87 |
4 |
| cleanup: |
| 88 |
4 |
▶ | if (cert_bio) BIO_free(cert_bio); |
Branch: 1 branch
| Branch | True | False | Total |
| if (cert_bio) BIO_free(cert_bio); |
4 |
0 |
4 |
|
| 89 |
4 |
▶ | if (key_bio) BIO_free(key_bio); |
Branch: 1 branch
| Branch | True | False | Total |
| if (key_bio) BIO_free(key_bio); |
4 |
0 |
4 |
|
| 90 |
4 |
▶ | if (x509) X509_free(x509); |
Branch: 1 branch
| Branch | True | False | Total |
| if (x509) X509_free(x509); |
4 |
0 |
4 |
|
| 91 |
4 |
▶ | if (pkey) EVP_PKEY_free(pkey); |
Branch: 1 branch
| Branch | True | False | Total |
| if (pkey) EVP_PKEY_free(pkey); |
4 |
0 |
4 |
|
| 92 |
4 |
▶ | if (pctx) EVP_PKEY_CTX_free(pctx); |
Branch: 1 branch
| Branch | True | False | Total |
| if (pctx) EVP_PKEY_CTX_free(pctx); |
4 |
0 |
4 |
|
| 93 |
4 |
| return ret; |
| 94 |
|
| } |
| 95 |
|
| |
| 96 |
|
| MODULE = Google::Auth PACKAGE = Google::Auth |
| 97 |
|
| |
| 98 |
|
| PROTOTYPES: ENABLE |
| 99 |
|
| |
| 100 |
|
| SV * |
| 101 |
|
| generate_self_signed_cert() |
| 102 |
|
| PREINIT: |
| 103 |
4 |
| char *cert_pem = NULL; |
| 104 |
4 |
| char *key_pem = NULL; |
| 105 |
4 |
| HV *hv = NULL; |
| 106 |
4 |
| SV *result = NULL; |
| 107 |
|
| CODE: |
| 108 |
4 |
▶ | if (generate_mock_cert(aTHX_ &cert_pem, &key_pem)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (generate_mock_cert(aTHX_ &cert_pem, &key_pem)) { |
4 |
0 |
4 |
|
| 109 |
4 |
| hv = newHV(); |
| 110 |
4 |
| hv_stores(hv, "cert", newSVpv(cert_pem, 0)); |
| 111 |
4 |
| hv_stores(hv, "key", newSVpv(key_pem, 0)); |
| 112 |
4 |
| result = newRV_noinc((SV *)hv); |
| 113 |
4 |
| Safefree(cert_pem); |
| 114 |
4 |
| Safefree(key_pem); |
| 115 |
|
| } else { |
| 116 |
0 |
| XSRETURN_UNDEF; |
| 117 |
|
| } |
| 118 |
4 |
| RETVAL = result; |
| 119 |
|
| OUTPUT: |
| 120 |
|
| RETVAL |
| 121 |
|
| |
| 122 |
|
| SV * |
| 123 |
|
| get_secure_random_bytes(int num_bytes) |
| 124 |
|
| PREINIT: |
| 125 |
0 |
| unsigned char *buf = NULL; |
| 126 |
0 |
| SV *retval = NULL; |
| 127 |
|
| CODE: |
| 128 |
0 |
▶ | if (num_bytes <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (num_bytes <= 0) { |
0 |
0 |
0 |
|
| 129 |
0 |
| XSRETURN_UNDEF; |
| 130 |
|
| } |
| 131 |
0 |
| Newx(buf, num_bytes, unsigned char); |
| 132 |
0 |
▶ | if (RAND_bytes(buf, num_bytes) == 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (RAND_bytes(buf, num_bytes) == 1) { |
0 |
0 |
0 |
|
| 133 |
0 |
| retval = newSVpv((char *)buf, num_bytes); |
| 134 |
0 |
| RETVAL = retval; |
| 135 |
|
| } else { |
| 136 |
0 |
| Safefree(buf); |
| 137 |
0 |
| XSRETURN_UNDEF; |
| 138 |
|
| } |
| 139 |
0 |
| Safefree(buf); |
| 140 |
|
| OUTPUT: |
| 141 |
|
| RETVAL |
| 142 |
|
| |
| 143 |
|
| #if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 144 |
|
| SV * |
| 145 |
|
| load_rsa_pubkey(SV *n_sv, SV *e_sv) |
| 146 |
|
| PREINIT: |
| 147 |
5 |
| unsigned char *n_bin = NULL; |
| 148 |
5 |
| unsigned char *e_bin = NULL; |
| 149 |
|
| STRLEN n_len, e_len; |
| 150 |
5 |
| EVP_PKEY *pkey = NULL; |
| 151 |
5 |
| RSA *rsa = NULL; |
| 152 |
5 |
| BIGNUM *n_bn = NULL; |
| 153 |
5 |
| BIGNUM *e_bn = NULL; |
| 154 |
5 |
| SV *retval = NULL; |
| 155 |
|
| CODE: |
| 156 |
5 |
▶ | n_bin = (unsigned char *)SvPV(n_sv, n_len); |
Branch: 1 branch
| Branch | True | False | Total |
| n_bin = (unsigned char *)SvPV(n_sv, n_len); |
5 |
0 |
5 |
|
| 157 |
5 |
| e_bin = (unsigned char *)SvPV(e_sv, e_len); |
| 158 |
|
| |
| 159 |
5 |
| OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new(); |
| 160 |
5 |
| OSSL_PARAM *params = NULL; |
| 161 |
5 |
| EVP_PKEY_CTX *pctx = NULL; |
| 162 |
|
| |
| 163 |
5 |
▶ | if (!bld) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!bld) XSRETURN_UNDEF; |
0 |
5 |
5 |
|
| 164 |
|
| |
| 165 |
5 |
| n_bn = BN_bin2bn(n_bin, n_len, NULL); |
| 166 |
5 |
| e_bn = BN_bin2bn(e_bin, e_len, NULL); |
| 167 |
5 |
▶ | if (!n_bn || !e_bn) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!n_bn || !e_bn) { |
5 |
0 |
5 |
| if (!n_bn || !e_bn) { |
0 |
5 |
5 |
|
| 168 |
0 |
▶ | if (n_bn) BN_free(n_bn); |
Branch: 1 branch
| Branch | True | False | Total |
| if (n_bn) BN_free(n_bn); |
0 |
0 |
0 |
|
| 169 |
0 |
▶ | if (e_bn) BN_free(e_bn); |
Branch: 1 branch
| Branch | True | False | Total |
| if (e_bn) BN_free(e_bn); |
0 |
0 |
0 |
|
| 170 |
0 |
| OSSL_PARAM_BLD_free(bld); |
| 171 |
0 |
| XSRETURN_UNDEF; |
| 172 |
|
| } |
| 173 |
|
| |
| 174 |
10 |
| if (!OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_N, n_bn) || |
| 175 |
5 |
| !OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_E, e_bn)) { |
| 176 |
0 |
| BN_free(n_bn); |
| 177 |
0 |
| BN_free(e_bn); |
| 178 |
0 |
| OSSL_PARAM_BLD_free(bld); |
| 179 |
0 |
| XSRETURN_UNDEF; |
| 180 |
|
| } |
| 181 |
|
| |
| 182 |
5 |
| params = OSSL_PARAM_BLD_to_param(bld); |
| 183 |
5 |
| pctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL); |
| 184 |
5 |
▶ | if (pctx && params) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (pctx && params) { |
5 |
0 |
5 |
| if (pctx && params) { |
5 |
0 |
5 |
|
| 185 |
5 |
▶ | if (EVP_PKEY_fromdata_init(pctx) > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (EVP_PKEY_fromdata_init(pctx) > 0) { |
5 |
0 |
5 |
|
| 186 |
5 |
| EVP_PKEY_fromdata(pctx, &pkey, EVP_PKEY_PUBLIC_KEY, params); |
| 187 |
|
| } |
| 188 |
|
| } |
| 189 |
|
| |
| 190 |
5 |
▶ | if (params) OSSL_PARAM_free(params); |
Branch: 1 branch
| Branch | True | False | Total |
| if (params) OSSL_PARAM_free(params); |
5 |
0 |
5 |
|
| 191 |
5 |
▶ | if (bld) OSSL_PARAM_BLD_free(bld); |
Branch: 1 branch
| Branch | True | False | Total |
| if (bld) OSSL_PARAM_BLD_free(bld); |
5 |
0 |
5 |
|
| 192 |
5 |
▶ | if (pctx) EVP_PKEY_CTX_free(pctx); |
Branch: 1 branch
| Branch | True | False | Total |
| if (pctx) EVP_PKEY_CTX_free(pctx); |
5 |
0 |
5 |
|
| 193 |
5 |
| BN_free(n_bn); |
| 194 |
5 |
| BN_free(e_bn); |
| 195 |
|
| |
| 196 |
5 |
▶ | if (!pkey) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pkey) XSRETURN_UNDEF; |
0 |
5 |
5 |
|
| 197 |
|
| |
| 198 |
5 |
| retval = newSViv(PTR2IV(pkey)); |
| 199 |
5 |
| retval = newRV_noinc(retval); |
| 200 |
5 |
| sv_bless(retval, gv_stashpv("Google::Auth::PublicKey", 1)); |
| 201 |
|
| |
| 202 |
5 |
| RETVAL = retval; |
| 203 |
|
| OUTPUT: |
| 204 |
|
| RETVAL |
| 205 |
|
| |
| 206 |
|
| #else |
| 207 |
|
| |
| 208 |
|
| SV * |
| 209 |
|
| load_rsa_pubkey(SV *n_sv, SV *e_sv) |
| 210 |
|
| PREINIT: |
| 211 |
|
| unsigned char *n_bin = NULL; |
| 212 |
|
| unsigned char *e_bin = NULL; |
| 213 |
|
| STRLEN n_len, e_len; |
| 214 |
|
| EVP_PKEY *pkey = NULL; |
| 215 |
|
| RSA *rsa = NULL; |
| 216 |
|
| BIGNUM *n_bn = NULL; |
| 217 |
|
| BIGNUM *e_bn = NULL; |
| 218 |
|
| SV *retval = NULL; |
| 219 |
|
| CODE: |
| 220 |
|
| n_bin = (unsigned char *)SvPV(n_sv, n_len); |
| 221 |
|
| e_bin = (unsigned char *)SvPV(e_sv, e_len); |
| 222 |
|
| |
| 223 |
|
| rsa = RSA_new(); |
| 224 |
|
| if (!rsa) XSRETURN_UNDEF; |
| 225 |
|
| |
| 226 |
|
| n_bn = BN_bin2bn(n_bin, n_len, NULL); |
| 227 |
|
| e_bn = BN_bin2bn(e_bin, e_len, NULL); |
| 228 |
|
| if (!n_bn || !e_bn) { |
| 229 |
|
| if (n_bn) BN_free(n_bn); |
| 230 |
|
| if (e_bn) BN_free(e_bn); |
| 231 |
|
| RSA_free(rsa); |
| 232 |
|
| XSRETURN_UNDEF; |
| 233 |
|
| } |
| 234 |
|
| |
| 235 |
|
| if (RSA_set0_key(rsa, n_bn, e_bn, NULL) <= 0) { |
| 236 |
|
| BN_free(n_bn); |
| 237 |
|
| BN_free(e_bn); |
| 238 |
|
| RSA_free(rsa); |
| 239 |
|
| XSRETURN_UNDEF; |
| 240 |
|
| } |
| 241 |
|
| |
| 242 |
|
| pkey = EVP_PKEY_new(); |
| 243 |
|
| if (!pkey) { |
| 244 |
|
| RSA_free(rsa); |
| 245 |
|
| XSRETURN_UNDEF; |
| 246 |
|
| } |
| 247 |
|
| |
| 248 |
|
| if (EVP_PKEY_assign_RSA(pkey, rsa) <= 0) { |
| 249 |
|
| RSA_free(rsa); |
| 250 |
|
| EVP_PKEY_free(pkey); |
| 251 |
|
| XSRETURN_UNDEF; |
| 252 |
|
| } |
| 253 |
|
| |
| 254 |
|
| retval = newSViv(PTR2IV(pkey)); |
| 255 |
|
| retval = newRV_noinc(retval); |
| 256 |
|
| sv_bless(retval, gv_stashpv("Google::Auth::PublicKey", 1)); |
| 257 |
|
| |
| 258 |
|
| RETVAL = retval; |
| 259 |
|
| OUTPUT: |
| 260 |
|
| RETVAL |
| 261 |
|
| |
| 262 |
|
| #endif |
| 263 |
|
| |
| 264 |
|
| #if OPENSSL_VERSION_NUMBER >= 0x30000000L |
| 265 |
|
| SV * |
| 266 |
|
| load_ec_pubkey(const char *curve_name, SV *x_sv, SV *y_sv) |
| 267 |
|
| PREINIT: |
| 268 |
8 |
| unsigned char *x_bin = NULL; |
| 269 |
8 |
| unsigned char *y_bin = NULL; |
| 270 |
|
| STRLEN x_len, y_len; |
| 271 |
8 |
| EVP_PKEY *pkey = NULL; |
| 272 |
8 |
| EC_KEY *eckey = NULL; |
| 273 |
8 |
| EC_GROUP *group = NULL; |
| 274 |
8 |
| EC_POINT *point = NULL; |
| 275 |
8 |
| BIGNUM *x_bn = NULL; |
| 276 |
8 |
| BIGNUM *y_bn = NULL; |
| 277 |
|
| int nid; |
| 278 |
8 |
| SV *retval = NULL; |
| 279 |
|
| CODE: |
| 280 |
8 |
▶ | x_bin = (unsigned char *)SvPV(x_sv, x_len); |
Branch: 1 branch
| Branch | True | False | Total |
| x_bin = (unsigned char *)SvPV(x_sv, x_len); |
8 |
0 |
8 |
|
| 281 |
8 |
| y_bin = (unsigned char *)SvPV(y_sv, y_len); |
| 282 |
|
| |
| 283 |
8 |
| nid = EC_curve_nist2nid(curve_name); |
| 284 |
8 |
▶ | if (nid == NID_undef) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nid == NID_undef) { |
7 |
1 |
8 |
|
| 285 |
7 |
| nid = OBJ_txt2nid(curve_name); |
| 286 |
|
| } |
| 287 |
8 |
▶ | if (nid == NID_undef) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (nid == NID_undef) XSRETURN_UNDEF; |
0 |
8 |
8 |
|
| 288 |
|
| |
| 289 |
8 |
| OSSL_PARAM_BLD *bld = OSSL_PARAM_BLD_new(); |
| 290 |
8 |
| OSSL_PARAM *params = NULL; |
| 291 |
8 |
| EVP_PKEY_CTX *pctx = NULL; |
| 292 |
|
| unsigned char point_bin[1 + 256]; |
| 293 |
8 |
| size_t point_len = 1 + x_len + y_len; |
| 294 |
|
| |
| 295 |
8 |
▶ | if (!bld || point_len > sizeof(point_bin)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (!bld || point_len > sizeof(point_bin)) { |
8 |
0 |
8 |
| if (!bld || point_len > sizeof(point_bin)) { |
0 |
8 |
8 |
|
| 296 |
0 |
▶ | if (bld) OSSL_PARAM_BLD_free(bld); |
Branch: 1 branch
| Branch | True | False | Total |
| if (bld) OSSL_PARAM_BLD_free(bld); |
0 |
0 |
0 |
|
| 297 |
0 |
| XSRETURN_UNDEF; |
| 298 |
|
| } |
| 299 |
|
| |
| 300 |
8 |
| point_bin[0] = 0x04; |
| 301 |
8 |
| memcpy(point_bin + 1, x_bin, x_len); |
| 302 |
8 |
| memcpy(point_bin + 1 + x_len, y_bin, y_len); |
| 303 |
|
| |
| 304 |
16 |
| if (!OSSL_PARAM_BLD_push_utf8_string(bld, OSSL_PKEY_PARAM_GROUP_NAME, (char *)curve_name, 0) || |
| 305 |
8 |
| !OSSL_PARAM_BLD_push_octet_string(bld, OSSL_PKEY_PARAM_PUB_KEY, point_bin, point_len)) { |
| 306 |
0 |
| OSSL_PARAM_BLD_free(bld); |
| 307 |
0 |
| XSRETURN_UNDEF; |
| 308 |
|
| } |
| 309 |
|
| |
| 310 |
8 |
| params = OSSL_PARAM_BLD_to_param(bld); |
| 311 |
8 |
| pctx = EVP_PKEY_CTX_new_from_name(NULL, "EC", NULL); |
| 312 |
8 |
▶ | if (pctx && params) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (pctx && params) { |
8 |
0 |
8 |
| if (pctx && params) { |
8 |
0 |
8 |
|
| 313 |
8 |
▶ | if (EVP_PKEY_fromdata_init(pctx) > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (EVP_PKEY_fromdata_init(pctx) > 0) { |
8 |
0 |
8 |
|
| 314 |
8 |
| EVP_PKEY_fromdata(pctx, &pkey, EVP_PKEY_PUBLIC_KEY, params); |
| 315 |
|
| } |
| 316 |
|
| } |
| 317 |
|
| |
| 318 |
8 |
▶ | if (params) OSSL_PARAM_free(params); |
Branch: 1 branch
| Branch | True | False | Total |
| if (params) OSSL_PARAM_free(params); |
8 |
0 |
8 |
|
| 319 |
8 |
▶ | if (bld) OSSL_PARAM_BLD_free(bld); |
Branch: 1 branch
| Branch | True | False | Total |
| if (bld) OSSL_PARAM_BLD_free(bld); |
8 |
0 |
8 |
|
| 320 |
8 |
▶ | if (pctx) EVP_PKEY_CTX_free(pctx); |
Branch: 1 branch
| Branch | True | False | Total |
| if (pctx) EVP_PKEY_CTX_free(pctx); |
8 |
0 |
8 |
|
| 321 |
|
| |
| 322 |
8 |
▶ | if (!pkey) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pkey) XSRETURN_UNDEF; |
0 |
8 |
8 |
|
| 323 |
|
| |
| 324 |
8 |
| retval = newSViv(PTR2IV(pkey)); |
| 325 |
8 |
| retval = newRV_noinc(retval); |
| 326 |
8 |
| sv_bless(retval, gv_stashpv("Google::Auth::PublicKey", 1)); |
| 327 |
|
| |
| 328 |
8 |
| RETVAL = retval; |
| 329 |
|
| OUTPUT: |
| 330 |
|
| RETVAL |
| 331 |
|
| |
| 332 |
|
| #else |
| 333 |
|
| |
| 334 |
|
| SV * |
| 335 |
|
| load_ec_pubkey(const char *curve_name, SV *x_sv, SV *y_sv) |
| 336 |
|
| PREINIT: |
| 337 |
|
| unsigned char *x_bin = NULL; |
| 338 |
|
| unsigned char *y_bin = NULL; |
| 339 |
|
| STRLEN x_len, y_len; |
| 340 |
|
| EVP_PKEY *pkey = NULL; |
| 341 |
|
| EC_KEY *eckey = NULL; |
| 342 |
|
| EC_GROUP *group = NULL; |
| 343 |
|
| EC_POINT *point = NULL; |
| 344 |
|
| BIGNUM *x_bn = NULL; |
| 345 |
|
| BIGNUM *y_bn = NULL; |
| 346 |
|
| int nid; |
| 347 |
|
| SV *retval = NULL; |
| 348 |
|
| CODE: |
| 349 |
|
| x_bin = (unsigned char *)SvPV(x_sv, x_len); |
| 350 |
|
| y_bin = (unsigned char *)SvPV(y_sv, y_len); |
| 351 |
|
| |
| 352 |
|
| nid = EC_curve_nist2nid(curve_name); |
| 353 |
|
| if (nid == NID_undef) { |
| 354 |
|
| nid = OBJ_txt2nid(curve_name); |
| 355 |
|
| } |
| 356 |
|
| if (nid == NID_undef) XSRETURN_UNDEF; |
| 357 |
|
| |
| 358 |
|
| eckey = EC_KEY_new(); |
| 359 |
|
| if (!eckey) XSRETURN_UNDEF; |
| 360 |
|
| |
| 361 |
|
| group = EC_GROUP_new_by_curve_name(nid); |
| 362 |
|
| if (!group) { |
| 363 |
|
| EC_KEY_free(eckey); |
| 364 |
|
| XSRETURN_UNDEF; |
| 365 |
|
| } |
| 366 |
|
| |
| 367 |
|
| if (EC_KEY_set_group(eckey, group) <= 0) { |
| 368 |
|
| EC_GROUP_free(group); |
| 369 |
|
| EC_KEY_free(eckey); |
| 370 |
|
| XSRETURN_UNDEF; |
| 371 |
|
| } |
| 372 |
|
| |
| 373 |
|
| point = EC_POINT_new(group); |
| 374 |
|
| if (!point) { |
| 375 |
|
| EC_GROUP_free(group); |
| 376 |
|
| EC_KEY_free(eckey); |
| 377 |
|
| XSRETURN_UNDEF; |
| 378 |
|
| } |
| 379 |
|
| |
| 380 |
|
| x_bn = BN_bin2bn(x_bin, x_len, NULL); |
| 381 |
|
| y_bn = BN_bin2bn(y_bin, y_len, NULL); |
| 382 |
|
| if (!x_bn || !y_bn) { |
| 383 |
|
| if (x_bn) BN_free(x_bn); |
| 384 |
|
| if (y_bn) BN_free(y_bn); |
| 385 |
|
| EC_POINT_free(point); |
| 386 |
|
| EC_GROUP_free(group); |
| 387 |
|
| EC_KEY_free(eckey); |
| 388 |
|
| XSRETURN_UNDEF; |
| 389 |
|
| } |
| 390 |
|
| |
| 391 |
|
| if (EC_POINT_set_affine_coordinates_GFp(group, point, x_bn, y_bn, NULL) <= 0) { |
| 392 |
|
| BN_free(x_bn); |
| 393 |
|
| BN_free(y_bn); |
| 394 |
|
| EC_POINT_free(point); |
| 395 |
|
| EC_GROUP_free(group); |
| 396 |
|
| EC_KEY_free(eckey); |
| 397 |
|
| XSRETURN_UNDEF; |
| 398 |
|
| } |
| 399 |
|
| |
| 400 |
|
| if (EC_KEY_set_public_key(eckey, point) <= 0) { |
| 401 |
|
| BN_free(x_bn); |
| 402 |
|
| BN_free(y_bn); |
| 403 |
|
| EC_POINT_free(point); |
| 404 |
|
| EC_GROUP_free(group); |
| 405 |
|
| EC_KEY_free(eckey); |
| 406 |
|
| XSRETURN_UNDEF; |
| 407 |
|
| } |
| 408 |
|
| |
| 409 |
|
| pkey = EVP_PKEY_new(); |
| 410 |
|
| if (!pkey) { |
| 411 |
|
| BN_free(x_bn); |
| 412 |
|
| BN_free(y_bn); |
| 413 |
|
| EC_POINT_free(point); |
| 414 |
|
| EC_GROUP_free(group); |
| 415 |
|
| EC_KEY_free(eckey); |
| 416 |
|
| XSRETURN_UNDEF; |
| 417 |
|
| } |
| 418 |
|
| |
| 419 |
|
| if (EVP_PKEY_assign_EC_KEY(pkey, eckey) <= 0) { |
| 420 |
|
| BN_free(x_bn); |
| 421 |
|
| BN_free(y_bn); |
| 422 |
|
| EC_POINT_free(point); |
| 423 |
|
| EC_GROUP_free(group); |
| 424 |
|
| EC_KEY_free(eckey); |
| 425 |
|
| EVP_PKEY_free(pkey); |
| 426 |
|
| XSRETURN_UNDEF; |
| 427 |
|
| } |
| 428 |
|
| |
| 429 |
|
| BN_free(x_bn); |
| 430 |
|
| BN_free(y_bn); |
| 431 |
|
| EC_POINT_free(point); |
| 432 |
|
| EC_GROUP_free(group); |
| 433 |
|
| |
| 434 |
|
| retval = newSViv(PTR2IV(pkey)); |
| 435 |
|
| retval = newRV_noinc(retval); |
| 436 |
|
| sv_bless(retval, gv_stashpv("Google::Auth::PublicKey", 1)); |
| 437 |
|
| |
| 438 |
|
| RETVAL = retval; |
| 439 |
|
| OUTPUT: |
| 440 |
|
| RETVAL |
| 441 |
|
| |
| 442 |
|
| #endif |
| 443 |
|
| |
| 444 |
|
| SV * |
| 445 |
|
| load_pubkey_from_x509_cert(SV *cert_pem_sv) |
| 446 |
|
| PREINIT: |
| 447 |
4 |
| char *pem_str = NULL; |
| 448 |
|
| STRLEN pem_len; |
| 449 |
4 |
| BIO *bio = NULL; |
| 450 |
4 |
| X509 *x509 = NULL; |
| 451 |
4 |
| EVP_PKEY *pkey = NULL; |
| 452 |
4 |
| SV *retval = NULL; |
| 453 |
|
| CODE: |
| 454 |
4 |
| pem_str = SvPV(cert_pem_sv, pem_len); |
| 455 |
4 |
| bio = BIO_new_mem_buf(pem_str, pem_len); |
| 456 |
5 |
▶ | if (!bio) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!bio) XSRETURN_UNDEF; |
0 |
4 |
4 |
|
| 457 |
|
| |
| 458 |
4 |
| x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL); |
| 459 |
4 |
| BIO_free(bio); |
| 460 |
4 |
▶ | if (!x509) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!x509) XSRETURN_UNDEF; |
1 |
3 |
4 |
|
| 461 |
|
| |
| 462 |
3 |
| pkey = X509_get_pubkey(x509); |
| 463 |
3 |
| X509_free(x509); |
| 464 |
3 |
▶ | if (!pkey) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pkey) XSRETURN_UNDEF; |
0 |
3 |
3 |
|
| 465 |
|
| |
| 466 |
3 |
| retval = newSViv(PTR2IV(pkey)); |
| 467 |
3 |
| retval = newRV_noinc(retval); |
| 468 |
3 |
| sv_bless(retval, gv_stashpv("Google::Auth::PublicKey", 1)); |
| 469 |
|
| |
| 470 |
3 |
| RETVAL = retval; |
| 471 |
|
| OUTPUT: |
| 472 |
|
| RETVAL |
| 473 |
|
| |
| 474 |
|
| int |
| 475 |
|
| verify_signature(SV *key_obj_sv, SV *message_sv, SV *signature_sv) |
| 476 |
|
| PREINIT: |
| 477 |
16 |
| EVP_PKEY *pkey = NULL; |
| 478 |
16 |
| char *msg_str = NULL; |
| 479 |
16 |
| char *sig_str = NULL; |
| 480 |
|
| STRLEN msg_len, sig_len; |
| 481 |
16 |
| EVP_MD_CTX *mdctx = NULL; |
| 482 |
16 |
| int verify_res = 0; |
| 483 |
16 |
| unsigned char *actual_sig = NULL; |
| 484 |
16 |
| unsigned int actual_sig_len = 0; |
| 485 |
16 |
| unsigned char *der_buf = NULL; |
| 486 |
16 |
▶ | ECDSA_SIG *ec_sig = NULL; |
Branch: 1 branch
| Branch | True | False | Total |
| ECDSA_SIG *ec_sig = NULL; |
16 |
0 |
16 |
|
| 487 |
|
| CODE: |
| 488 |
16 |
▶ | if (sv_derived_from(key_obj_sv, "Google::Auth::PublicKey")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_derived_from(key_obj_sv, "Google::Auth::PublicKey")) { |
16 |
0 |
16 |
|
| 489 |
16 |
| IV tmp = SvIV((SV*)SvRV(key_obj_sv)); |
| 490 |
16 |
| pkey = INT2PTR(EVP_PKEY *, tmp); |
| 491 |
|
| } |
| 492 |
16 |
▶ | if (!pkey) XSRETURN_NO; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pkey) XSRETURN_NO; |
0 |
16 |
16 |
|
| 493 |
|
| |
| 494 |
16 |
▶ | msg_str = SvPV(message_sv, msg_len); |
Branch: 1 branch
| Branch | True | False | Total |
| msg_str = SvPV(message_sv, msg_len); |
16 |
0 |
16 |
|
| 495 |
16 |
| sig_str = SvPV(signature_sv, sig_len); |
| 496 |
|
| |
| 497 |
16 |
| actual_sig = (unsigned char *)sig_str; |
| 498 |
16 |
| actual_sig_len = sig_len; |
| 499 |
|
| |
| 500 |
16 |
▶ | if (EVP_PKEY_base_id(pkey) == EVP_PKEY_EC) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (EVP_PKEY_base_id(pkey) == EVP_PKEY_EC) { |
4 |
12 |
16 |
|
| 501 |
4 |
▶ | if (sig_len % 2 == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sig_len % 2 == 0) { |
4 |
0 |
4 |
|
| 502 |
4 |
| int half_len = sig_len / 2; |
| 503 |
4 |
| BIGNUM *r_bn = BN_bin2bn((unsigned char *)sig_str, half_len, NULL); |
| 504 |
4 |
| BIGNUM *s_bn = BN_bin2bn((unsigned char *)sig_str + half_len, half_len, NULL); |
| 505 |
4 |
▶ | if (r_bn && s_bn) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (r_bn && s_bn) { |
4 |
0 |
4 |
| if (r_bn && s_bn) { |
4 |
0 |
4 |
|
| 506 |
4 |
| ec_sig = ECDSA_SIG_new(); |
| 507 |
4 |
▶ | if (ec_sig) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ec_sig) { |
4 |
0 |
4 |
|
| 508 |
4 |
| ECDSA_SIG_set0(ec_sig, r_bn, s_bn); |
| 509 |
4 |
| int der_len = i2d_ECDSA_SIG(ec_sig, NULL); |
| 510 |
4 |
▶ | if (der_len > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (der_len > 0) { |
4 |
0 |
4 |
|
| 511 |
4 |
| Newx(der_buf, der_len, unsigned char); |
| 512 |
4 |
▶ | if (der_buf) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (der_buf) { |
4 |
0 |
4 |
|
| 513 |
4 |
| unsigned char *p = der_buf; |
| 514 |
4 |
| i2d_ECDSA_SIG(ec_sig, &p); |
| 515 |
4 |
| actual_sig = der_buf; |
| 516 |
4 |
| actual_sig_len = der_len; |
| 517 |
|
| } |
| 518 |
|
| } |
| 519 |
|
| } else { |
| 520 |
0 |
| BN_free(r_bn); |
| 521 |
0 |
| BN_free(s_bn); |
| 522 |
|
| } |
| 523 |
|
| } |
| 524 |
|
| } |
| 525 |
|
| } |
| 526 |
|
| |
| 527 |
16 |
| mdctx = EVP_MD_CTX_new(); |
| 528 |
16 |
▶ | if (mdctx) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (mdctx) { |
16 |
0 |
16 |
|
| 529 |
32 |
| if (EVP_VerifyInit_ex(mdctx, EVP_sha256(), NULL) > 0 && |
| 530 |
16 |
| EVP_VerifyUpdate(mdctx, msg_str, msg_len) > 0) { |
| 531 |
16 |
| verify_res = EVP_VerifyFinal(mdctx, actual_sig, actual_sig_len, pkey); |
| 532 |
|
| } |
| 533 |
16 |
| EVP_MD_CTX_free(mdctx); |
| 534 |
|
| } |
| 535 |
|
| |
| 536 |
16 |
▶ | if (ec_sig) ECDSA_SIG_free(ec_sig); |
Branch: 1 branch
| Branch | True | False | Total |
| if (ec_sig) ECDSA_SIG_free(ec_sig); |
4 |
12 |
16 |
|
| 537 |
16 |
▶ | if (der_buf) Safefree(der_buf); |
Branch: 1 branch
| Branch | True | False | Total |
| if (der_buf) Safefree(der_buf); |
4 |
12 |
16 |
|
| 538 |
|
| |
| 539 |
16 |
▶ | if (verify_res > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (verify_res > 0) { |
10 |
6 |
16 |
|
| 540 |
10 |
| XSRETURN_YES; |
| 541 |
|
| } else { |
| 542 |
6 |
| XSRETURN_NO; |
| 543 |
|
| } |
| 544 |
|
| |
| 545 |
|
| SV * |
| 546 |
|
| rsa_sign_sha256(SV *private_key_pem_sv, SV *message_sv) |
| 547 |
|
| PREINIT: |
| 548 |
4 |
| char *pem_str = NULL; |
| 549 |
4 |
| char *msg_str = NULL; |
| 550 |
|
| STRLEN pem_len, msg_len; |
| 551 |
4 |
| BIO *bio = NULL; |
| 552 |
4 |
| EVP_PKEY *pkey = NULL; |
| 553 |
4 |
| EVP_MD_CTX *mdctx = NULL; |
| 554 |
|
| unsigned char sig[4096]; |
| 555 |
4 |
| unsigned int sig_len = 0; |
| 556 |
4 |
| SV *retval = NULL; |
| 557 |
|
| CODE: |
| 558 |
4 |
▶ | pem_str = SvPV(private_key_pem_sv, pem_len); |
Branch: 1 branch
| Branch | True | False | Total |
| pem_str = SvPV(private_key_pem_sv, pem_len); |
4 |
0 |
4 |
|
| 559 |
4 |
| msg_str = SvPV(message_sv, msg_len); |
| 560 |
|
| |
| 561 |
4 |
| bio = BIO_new_mem_buf(pem_str, pem_len); |
| 562 |
4 |
▶ | if (!bio) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!bio) XSRETURN_UNDEF; |
0 |
4 |
4 |
|
| 563 |
|
| |
| 564 |
4 |
| pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL); |
| 565 |
4 |
| BIO_free(bio); |
| 566 |
4 |
▶ | if (!pkey) XSRETURN_UNDEF; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!pkey) XSRETURN_UNDEF; |
0 |
4 |
4 |
|
| 567 |
|
| |
| 568 |
4 |
| mdctx = EVP_MD_CTX_new(); |
| 569 |
4 |
▶ | if (!mdctx) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!mdctx) { |
0 |
4 |
4 |
|
| 570 |
0 |
| EVP_PKEY_free(pkey); |
| 571 |
0 |
| XSRETURN_UNDEF; |
| 572 |
|
| } |
| 573 |
|
| |
| 574 |
8 |
| if (EVP_SignInit_ex(mdctx, EVP_sha256(), NULL) <= 0 || |
| 575 |
8 |
▶ | EVP_SignUpdate(mdctx, msg_str, msg_len) <= 0 || |
Branch: 1 branch
| Branch | True | False | Total |
| EVP_SignUpdate(mdctx, msg_str, msg_len) <= 0 || |
0 |
4 |
4 |
|
| 576 |
4 |
| EVP_SignFinal(mdctx, sig, &sig_len, pkey) <= 0) { |
| 577 |
0 |
| EVP_MD_CTX_free(mdctx); |
| 578 |
0 |
| EVP_PKEY_free(pkey); |
| 579 |
0 |
| XSRETURN_UNDEF; |
| 580 |
|
| } |
| 581 |
|
| |
| 582 |
4 |
| EVP_MD_CTX_free(mdctx); |
| 583 |
4 |
| EVP_PKEY_free(pkey); |
| 584 |
|
| |
| 585 |
4 |
| retval = newSVpv((char *)sig, sig_len); |
| 586 |
4 |
| RETVAL = retval; |
| 587 |
|
| OUTPUT: |
| 588 |
|
| RETVAL |
| 589 |
|
| |
| 590 |
|
| MODULE = Google::Auth PACKAGE = Google::Auth::PublicKey |
| 591 |
|
| |
| 592 |
|
| void |
| 593 |
|
| DESTROY(self) |
| 594 |
|
| SV *self |
| 595 |
|
| PREINIT: |
| 596 |
16 |
| EVP_PKEY *pkey = NULL; |
| 597 |
|
| CODE: |
| 598 |
16 |
▶ | if (sv_derived_from(self, "Google::Auth::PublicKey")) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (sv_derived_from(self, "Google::Auth::PublicKey")) { |
16 |
0 |
16 |
|
| 599 |
16 |
| IV tmp = SvIV((SV*)SvRV(self)); |
| 600 |
16 |
| pkey = INT2PTR(EVP_PKEY *, tmp); |
| 601 |
16 |
▶ | if (pkey) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (pkey) { |
16 |
0 |
16 |
|
| 602 |
16 |
| EVP_PKEY_free(pkey); |
| 603 |
|
| } |
| 604 |
|
| } |