| 1 | /* |
| 2 | * Copyright (c) 2004 - 2007 Kungliga Tekniska Högskolan |
| 3 | * (Royal Institute of Technology, Stockholm, Sweden). |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
| 9 | * |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * |
| 17 | * 3. Neither the name of the Institute nor the names of its contributors |
| 18 | * may be used to endorse or promote products derived from this software |
| 19 | * without specific prior written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND |
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE |
| 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 31 | * SUCH DAMAGE. |
| 32 | */ |
| 33 | |
| 34 | #include "hx_locl.h"cxx . . $ `<file>/lib/hx509/hx_locl.h`/ |
| 35 | |
| 36 | struct ks_pkcs12cxx . . $ ks_pkcs12# { |
| 37 | hx509_certscxx . . $ hx509_certs# certscxx . . $ ks_pkcs12#certs.; |
| 38 | char *fncxx . . $ ks_pkcs12#fn.; |
| 39 | }; |
| 40 | |
| 41 | typedef int (*collector_funccxx . . $ collector_func#)(hx509_contextcxx . . $ hx509_context#, |
| 42 | struct hx509_collectorcxx . . $ hx509_collector# *, |
| 43 | const void *, size_t, |
| 44 | const PKCS12_Attributescxx . . $ PKCS12_Attributes# *); |
| 45 | |
| 46 | struct typecxx . . $ type# { |
| 47 | const heim_oidcxx . . $ heim_oid# *oidcxx . . $ type#oid.; |
| 48 | collector_funccxx . . $ collector_func# funccxx . . $ type#func.; |
| 49 | }; |
| 50 | |
| 51 | static void |
| 52 | parse_pkcs12_typecxx . . $ parse_pkcs12_type(75323a9a1fd3dbf9).(hx509_contextcxx . . $ hx509_context#, struct hx509_collectorcxx . . $ hx509_collector# *, const heim_oidcxx . . $ heim_oid# *, |
| 53 | const void *, size_t, const PKCS12_Attributescxx . . $ PKCS12_Attributes# *); |
| 54 | |
| 55 | |
| 56 | static const PKCS12_Attributecxx . . $ PKCS12_Attribute# * |
| 57 | find_attributecxx . . $ find_attribute(6ab4e8d2bcddb2dc).(const PKCS12_Attributescxx . . $ PKCS12_Attributes# *attrs, const heim_oidcxx . . $ heim_oid# *oid) |
| 58 | { |
| 59 | size_t i; |
| 60 | if (attrs == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 61 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 62 | for (i = 0; i < attrs->lencxx . . $ PKCS12_Attributes#len.; i++) |
| 63 | if (der_heim_oid_cmpcxx . . $ der_heim_oid_cmp(57bc20a77f38f7ca).(oid, &attrs->valcxx . . $ PKCS12_Attributes#val.[i].attrIdcxx . . $ PKCS12_Attribute#attrId.) == 0) |
| 64 | return &attrs->valcxx . . $ PKCS12_Attributes#val.[i]; |
| 65 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 66 | } |
| 67 | |
| 68 | static int |
| 69 | keyBag_parsercxx . . $ keyBag_parser(db5c98bcf3c39c2e).(hx509_contextcxx . . $ hx509_context# context, |
| 70 | struct hx509_collectorcxx . . $ hx509_collector# *c, |
| 71 | const void *data, size_t length, |
| 72 | const PKCS12_Attributescxx . . $ PKCS12_Attributes# *attrs) |
| 73 | { |
| 74 | const PKCS12_Attributecxx . . $ PKCS12_Attribute# *attr; |
| 75 | PKCS8PrivateKeyInfocxx . . $ PKCS8PrivateKeyInfo# ki; |
| 76 | const heim_octet_stringcxx . . $ heim_octet_string# *os = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 77 | int ret; |
| 78 | |
| 79 | attr = find_attributecxx . . $ find_attribute(6ab4e8d2bcddb2dc).(attrs, &asn1_oid_id_pkcs_9_at_localKeyIdcxx . . $ asn1_oid_id_pkcs_9_at_localKeyId.); |
| 80 | if (attr) |
| 81 | os = &attr->attrValuescxx . . $ PKCS12_Attribute#attrValues.; |
| 82 | |
| 83 | ret = decode_PKCS8PrivateKeyInfocxx . . $ decode_PKCS8PrivateKeyInfo(8a49ee68744249ce).(data, length, &ki, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 84 | if (ret) |
| 85 | return ret; |
| 86 | |
| 87 | _hx509_collector_private_key_addcxx . . $ _hx509_collector_private_key_add(9677aedc230352a7).(context, |
| 88 | c, |
| 89 | &ki.privateKeyAlgorithmcxx . . $ PKCS8PrivateKeyInfo#privateKeyAlgorithm., |
| 90 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 91 | &ki.privateKeycxx . . $ PKCS8PrivateKeyInfo#privateKey., |
| 92 | os); |
| 93 | free_PKCS8PrivateKeyInfocxx . . $ free_PKCS8PrivateKeyInfo(ab6518dd27c45d78).(&ki); |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | static int |
| 98 | ShroudedKeyBag_parsercxx . . $ ShroudedKeyBag_parser(db5c98bcf3c39c2e).(hx509_contextcxx . . $ hx509_context# context, |
| 99 | struct hx509_collectorcxx . . $ hx509_collector# *c, |
| 100 | const void *data, size_t length, |
| 101 | const PKCS12_Attributescxx . . $ PKCS12_Attributes# *attrs) |
| 102 | { |
| 103 | PKCS8EncryptedPrivateKeyInfocxx . . $ PKCS8EncryptedPrivateKeyInfo# pk; |
| 104 | heim_octet_stringcxx . . $ heim_octet_string# content; |
| 105 | int ret; |
| 106 | |
| 107 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&pk, 0, sizeof(pk)); |
| 108 | |
| 109 | ret = decode_PKCS8EncryptedPrivateKeyInfocxx . . $ decode_PKCS8EncryptedPrivateKeyInfo(bb5443ed249358dd).(data, length, &pk, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 110 | if (ret) |
| 111 | return ret; |
| 112 | |
| 113 | ret = _hx509_pbe_decryptcxx . . $ _hx509_pbe_decrypt(9aa57f388a0eac79).(context, |
| 114 | _hx509_collector_get_lockcxx . . $ _hx509_collector_get_lock(46436d8ec15a22c6).(c), |
| 115 | &pk.encryptionAlgorithmcxx . . $ PKCS8EncryptedPrivateKeyInfo#encryptionAlgorithm., |
| 116 | &pk.encryptedDatacxx . . $ PKCS8EncryptedPrivateKeyInfo#encryptedData., |
| 117 | &content); |
| 118 | free_PKCS8EncryptedPrivateKeyInfocxx . . $ free_PKCS8EncryptedPrivateKeyInfo(338e1f41fc9f9693).(&pk); |
| 119 | if (ret) |
| 120 | return ret; |
| 121 | |
| 122 | ret = keyBag_parsercxx . . $ keyBag_parser(db5c98bcf3c39c2e).(context, c, content.datacxx . . $ heim_base_data#data., content.lengthcxx . . $ heim_base_data#length., attrs); |
| 123 | der_free_octet_stringcxx . . $ der_free_octet_string(8b8af749bc8ea7aa).(&content); |
| 124 | return ret; |
| 125 | } |
| 126 | |
| 127 | static int |
| 128 | certBag_parsercxx . . $ certBag_parser(db5c98bcf3c39c2e).(hx509_contextcxx . . $ hx509_context# context, |
| 129 | struct hx509_collectorcxx . . $ hx509_collector# *c, |
| 130 | const void *data, size_t length, |
| 131 | const PKCS12_Attributescxx . . $ PKCS12_Attributes# *attrs) |
| 132 | { |
| 133 | heim_error_tcxx . . $ heim_error_t# error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 134 | heim_octet_stringcxx . . $ heim_octet_string# os; |
| 135 | hx509_certcxx . . $ hx509_cert# cert; |
| 136 | PKCS12_CertBagcxx . . $ PKCS12_CertBag# cb; |
| 137 | int ret; |
| 138 | |
| 139 | ret = decode_PKCS12_CertBagcxx . . $ decode_PKCS12_CertBag(17577ba6db3b3d3d).(data, length, &cb, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 140 | if (ret) |
| 141 | return ret; |
| 142 | |
| 143 | if (der_heim_oid_cmpcxx . . $ der_heim_oid_cmp(57bc20a77f38f7ca).(&asn1_oid_id_pkcs_9_at_certTypes_x509cxx . . $ asn1_oid_id_pkcs_9_at_certTypes_x509., &cb.certTypecxx . . $ PKCS12_CertBag#certType.)) { |
| 144 | free_PKCS12_CertBagcxx . . $ free_PKCS12_CertBag(8b44870e99893800).(&cb); |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | ret = decode_PKCS12_OctetStringcxx . . $ decode_PKCS12_OctetString(8d625750367953f9).(cb.certValuecxx . . $ PKCS12_CertBag#certValue..datacxx . . $ heim_base_data#data., |
| 149 | cb.certValuecxx . . $ PKCS12_CertBag#certValue..lengthcxx . . $ heim_base_data#length., |
| 150 | &os, |
| 151 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 152 | free_PKCS12_CertBagcxx . . $ free_PKCS12_CertBag(8b44870e99893800).(&cb); |
| 153 | if (ret) |
| 154 | return ret; |
| 155 | |
| 156 | cert = hx509_cert_init_datacxx . . $ hx509_cert_init_data(5789adbc0562fc6e).(context, os.datacxx . . $ heim_base_data#data., os.lengthcxx . . $ heim_base_data#length., &error); |
| 157 | der_free_octet_stringcxx . . $ der_free_octet_string(8b8af749bc8ea7aa).(&os); |
| 158 | if (cert == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 159 | ret = heim_error_get_codecxx . . $ heim_error_get_code(a12d5a0948a20701).(error); |
| 160 | heim_releasecxx . . $ heim_release(5d22bdacc48458e8).(error); |
| 161 | return ret; |
| 162 | } |
| 163 | |
| 164 | ret = _hx509_collector_certs_addcxx . . $ _hx509_collector_certs_add(2713188675346810).(context, c, cert); |
| 165 | if (ret) { |
| 166 | hx509_cert_freecxx . . $ hx509_cert_free(a4bd42c4d5523b91).(cert); |
| 167 | return ret; |
| 168 | } |
| 169 | |
| 170 | { |
| 171 | const PKCS12_Attributecxx . . $ PKCS12_Attribute# *attr; |
| 172 | const heim_oidcxx . . $ heim_oid# *oids[] = { |
| 173 | &asn1_oid_id_pkcs_9_at_localKeyIdcxx . . $ asn1_oid_id_pkcs_9_at_localKeyId., &asn1_oid_id_pkcs_9_at_friendlyNamecxx . . $ asn1_oid_id_pkcs_9_at_friendlyName. |
| 174 | }; |
| 175 | size_t i; |
| 176 | |
| 177 | for (i = 0; i < sizeof(oids)/sizeof(oids[0]); i++) { |
| 178 | const heim_oidcxx . . $ heim_oid# *oid = oids[i]; |
| 179 | attr = find_attributecxx . . $ find_attribute(6ab4e8d2bcddb2dc).(attrs, oid); |
| 180 | if (attr) |
| 181 | _hx509_set_cert_attributecxx . . $ _hx509_set_cert_attribute(6548a3758e3d2132).(context, cert, oid, |
| 182 | &attr->attrValuescxx . . $ PKCS12_Attribute#attrValues.); |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | hx509_cert_freecxx . . $ hx509_cert_free(a4bd42c4d5523b91).(cert); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | static int |
| 192 | parse_safe_contentcxx . . $ parse_safe_content(ae6c1470e083e17c).(hx509_contextcxx . . $ hx509_context# context, |
| 193 | struct hx509_collectorcxx . . $ hx509_collector# *c, |
| 194 | const unsigned char *p, size_t len) |
| 195 | { |
| 196 | PKCS12_SafeContentscxx . . $ PKCS12_SafeContents# sc; |
| 197 | int ret; |
| 198 | size_t i; |
| 199 | |
| 200 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&sc, 0, sizeof(sc)); |
| 201 | |
| 202 | ret = decode_PKCS12_SafeContentscxx . . $ decode_PKCS12_SafeContents(9ed9314c3e2d650).(p, len, &sc, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 203 | if (ret) |
| 204 | return ret; |
| 205 | |
| 206 | for (i = 0; i < sc.lencxx . . $ PKCS12_SafeContents#len. ; i++) |
| 207 | parse_pkcs12_typecxx . . $ parse_pkcs12_type(75323a9a1fd3dbf9).(context, |
| 208 | c, |
| 209 | &sc.valcxx . . $ PKCS12_SafeContents#val.[i].bagIdcxx . . $ PKCS12_SafeBag#bagId., |
| 210 | sc.valcxx . . $ PKCS12_SafeContents#val.[i].bagValuecxx . . $ PKCS12_SafeBag#bagValue..datacxx . . $ heim_base_data#data., |
| 211 | sc.valcxx . . $ PKCS12_SafeContents#val.[i].bagValuecxx . . $ PKCS12_SafeBag#bagValue..lengthcxx . . $ heim_base_data#length., |
| 212 | sc.valcxx . . $ PKCS12_SafeContents#val.[i].bagAttributescxx . . $ PKCS12_SafeBag#bagAttributes.); |
| 213 | |
| 214 | free_PKCS12_SafeContentscxx . . $ free_PKCS12_SafeContents(81d211ed87d31c01).(&sc); |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | static int |
| 219 | safeContent_parsercxx . . $ safeContent_parser(db5c98bcf3c39c2e).(hx509_contextcxx . . $ hx509_context# context, |
| 220 | struct hx509_collectorcxx . . $ hx509_collector# *c, |
| 221 | const void *data, size_t length, |
| 222 | const PKCS12_Attributescxx . . $ PKCS12_Attributes# *attrs) |
| 223 | { |
| 224 | heim_octet_stringcxx . . $ heim_octet_string# os; |
| 225 | int ret; |
| 226 | |
| 227 | ret = decode_PKCS12_OctetStringcxx . . $ decode_PKCS12_OctetString(8d625750367953f9).(data, length, &os, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 228 | if (ret) |
| 229 | return ret; |
| 230 | ret = parse_safe_contentcxx . . $ parse_safe_content(ae6c1470e083e17c).(context, c, os.datacxx . . $ heim_base_data#data., os.lengthcxx . . $ heim_base_data#length.); |
| 231 | der_free_octet_stringcxx . . $ der_free_octet_string(8b8af749bc8ea7aa).(&os); |
| 232 | return ret; |
| 233 | } |
| 234 | |
| 235 | static int |
| 236 | encryptedData_parsercxx . . $ encryptedData_parser(db5c98bcf3c39c2e).(hx509_contextcxx . . $ hx509_context# context, |
| 237 | struct hx509_collectorcxx . . $ hx509_collector# *c, |
| 238 | const void *data, size_t length, |
| 239 | const PKCS12_Attributescxx . . $ PKCS12_Attributes# *attrs) |
| 240 | { |
| 241 | heim_octet_stringcxx . . $ heim_octet_string# content; |
| 242 | heim_oidcxx . . $ heim_oid# contentType; |
| 243 | int ret; |
| 244 | |
| 245 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&contentType, 0, sizeof(contentType)); |
| 246 | |
| 247 | ret = hx509_cms_decrypt_encryptedcxx . . $ hx509_cms_decrypt_encrypted(dcf4d5d49127e58b).(context, |
| 248 | _hx509_collector_get_lockcxx . . $ _hx509_collector_get_lock(46436d8ec15a22c6).(c), |
| 249 | data, length, |
| 250 | &contentType, |
| 251 | &content); |
| 252 | if (ret) |
| 253 | return ret; |
| 254 | |
| 255 | if (der_heim_oid_cmpcxx . . $ der_heim_oid_cmp(57bc20a77f38f7ca).(&contentType, &asn1_oid_id_pkcs7_datacxx . . $ asn1_oid_id_pkcs7_data.) == 0) |
| 256 | ret = parse_safe_contentcxx . . $ parse_safe_content(ae6c1470e083e17c).(context, c, content.datacxx . . $ heim_base_data#data., content.lengthcxx . . $ heim_base_data#length.); |
| 257 | |
| 258 | der_free_octet_stringcxx . . $ der_free_octet_string(8b8af749bc8ea7aa).(&content); |
| 259 | der_free_oidcxx . . $ der_free_oid(99c92d7caa6f2cbd).(&contentType); |
| 260 | return ret; |
| 261 | } |
| 262 | |
| 263 | static int |
| 264 | envelopedData_parsercxx . . $ envelopedData_parser(db5c98bcf3c39c2e).(hx509_contextcxx . . $ hx509_context# context, |
| 265 | struct hx509_collectorcxx . . $ hx509_collector# *c, |
| 266 | const void *data, size_t length, |
| 267 | const PKCS12_Attributescxx . . $ PKCS12_Attributes# *attrs) |
| 268 | { |
| 269 | heim_octet_stringcxx . . $ heim_octet_string# content; |
| 270 | heim_oidcxx . . $ heim_oid# contentType; |
| 271 | hx509_lockcxx . . $ hx509_lock# lock; |
| 272 | int ret; |
| 273 | |
| 274 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&contentType, 0, sizeof(contentType)); |
| 275 | |
| 276 | lock = _hx509_collector_get_lockcxx . . $ _hx509_collector_get_lock(46436d8ec15a22c6).(c); |
| 277 | |
| 278 | ret = hx509_cms_unenvelopecxx . . $ hx509_cms_unenvelope(d870bea1acc85488).(context, |
| 279 | _hx509_lock_unlock_certscxx . . $ _hx509_lock_unlock_certs(3b9404e45ef36a7b).(lock), |
| 280 | 0, |
| 281 | data, length, |
| 282 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 283 | 0, |
| 284 | &contentType, |
| 285 | &content); |
| 286 | if (ret) { |
| 287 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, HX509_ERROR_APPENDcxx . . $ `lib/hx509/hx509.h:138:9`!, ret, |
| 288 | "PKCS12 failed to unenvelope"); |
| 289 | return ret; |
| 290 | } |
| 291 | |
| 292 | if (der_heim_oid_cmpcxx . . $ der_heim_oid_cmp(57bc20a77f38f7ca).(&contentType, &asn1_oid_id_pkcs7_datacxx . . $ asn1_oid_id_pkcs7_data.) == 0) |
| 293 | ret = parse_safe_contentcxx . . $ parse_safe_content(ae6c1470e083e17c).(context, c, content.datacxx . . $ heim_base_data#data., content.lengthcxx . . $ heim_base_data#length.); |
| 294 | |
| 295 | der_free_octet_stringcxx . . $ der_free_octet_string(8b8af749bc8ea7aa).(&content); |
| 296 | der_free_oidcxx . . $ der_free_oid(99c92d7caa6f2cbd).(&contentType); |
| 297 | |
| 298 | return ret; |
| 299 | } |
| 300 | |
| 301 | |
| 302 | struct typecxx . . $ type# bagtypescxx . . $ bagtypes.[] = { |
| 303 | { &asn1_oid_id_pkcs12_keyBagcxx . . $ asn1_oid_id_pkcs12_keyBag., keyBag_parsercxx . . $ keyBag_parser(db5c98bcf3c39c2e). }, |
| 304 | { &asn1_oid_id_pkcs12_pkcs8ShroudedKeyBagcxx . . $ asn1_oid_id_pkcs12_pkcs8ShroudedKeyBag., ShroudedKeyBag_parsercxx . . $ ShroudedKeyBag_parser(db5c98bcf3c39c2e). }, |
| 305 | { &asn1_oid_id_pkcs12_certBagcxx . . $ asn1_oid_id_pkcs12_certBag., certBag_parsercxx . . $ certBag_parser(db5c98bcf3c39c2e). }, |
| 306 | { &asn1_oid_id_pkcs7_datacxx . . $ asn1_oid_id_pkcs7_data., safeContent_parsercxx . . $ safeContent_parser(db5c98bcf3c39c2e). }, |
| 307 | { &asn1_oid_id_pkcs7_encryptedDatacxx . . $ asn1_oid_id_pkcs7_encryptedData., encryptedData_parsercxx . . $ encryptedData_parser(db5c98bcf3c39c2e). }, |
| 308 | { &asn1_oid_id_pkcs7_envelopedDatacxx . . $ asn1_oid_id_pkcs7_envelopedData., envelopedData_parsercxx . . $ envelopedData_parser(db5c98bcf3c39c2e). } |
| 309 | }; |
| 310 | |
| 311 | static void |
| 312 | parse_pkcs12_typecxx . . $ parse_pkcs12_type(75323a9a1fd3dbf9).(hx509_contextcxx . . $ hx509_context# context, |
| 313 | struct hx509_collectorcxx . . $ hx509_collector# *c, |
| 314 | const heim_oidcxx . . $ heim_oid# *oid, |
| 315 | const void *data, size_t length, |
| 316 | const PKCS12_Attributescxx . . $ PKCS12_Attributes# *attrs) |
| 317 | { |
| 318 | size_t i; |
| 319 | |
| 320 | for (i = 0; i < sizeof(bagtypescxx . . $ bagtypes.)/sizeof(bagtypescxx . . $ bagtypes.[0]); i++) |
| 321 | if (der_heim_oid_cmpcxx . . $ der_heim_oid_cmp(57bc20a77f38f7ca).(bagtypescxx . . $ bagtypes.[i].oidcxx . . $ type#oid., oid) == 0) |
| 322 | (*bagtypescxx . . $ bagtypes.[i].funccxx . . $ type#func.)(context, c, data, length, attrs); |
| 323 | } |
| 324 | |
| 325 | static int |
| 326 | p12_initcxx . . $ p12_init(b8c8de8f8ec1b894).(hx509_contextcxx . . $ hx509_context# context, |
| 327 | hx509_certscxx . . $ hx509_certs# certs, void **data, int flags, |
| 328 | const char *residue, hx509_lockcxx . . $ hx509_lock# lock) |
| 329 | { |
| 330 | struct ks_pkcs12cxx . . $ ks_pkcs12# *p12; |
| 331 | size_t len; |
| 332 | void *buf; |
| 333 | PKCS12_PFXcxx . . $ PKCS12_PFX# pfx; |
| 334 | PKCS12_AuthenticatedSafecxx . . $ PKCS12_AuthenticatedSafe# as; |
| 335 | int ret; |
| 336 | size_t i; |
| 337 | struct hx509_collectorcxx . . $ hx509_collector# *c; |
| 338 | |
| 339 | *data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 340 | |
| 341 | if (lock == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) |
| 342 | lock = _hx509_empty_lockcxx . . $ _hx509_empty_lock.; |
| 343 | |
| 344 | ret = _hx509_collector_alloccxx . . $ _hx509_collector_alloc(37ce0e3606632c99).(context, lock, &c); |
| 345 | if (ret) |
| 346 | return ret; |
| 347 | |
| 348 | p12 = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*p12)); |
| 349 | if (p12 == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 350 | ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!; |
| 351 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, 0, ret, "out of memory"); |
| 352 | goto out; |
| 353 | } |
| 354 | |
| 355 | p12->fncxx . . $ ks_pkcs12#fn. = strdupcxx . . $ strdup(a8b8e32347182212).(residue); |
| 356 | if (p12->fncxx . . $ ks_pkcs12#fn. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 357 | ret = ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!; |
| 358 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, 0, ret, "out of memory"); |
| 359 | goto out; |
| 360 | } |
| 361 | |
| 362 | if (flags & HX509_CERTS_CREATEcxx . . $ `lib/hx509/hx509.h:134:9`!) { |
| 363 | ret = hx509_certs_initcxx . . $ hx509_certs_init(69cd6dcc0188a099).(context, "MEMORY:ks-file-create", |
| 364 | 0, lock, &p12->certscxx . . $ ks_pkcs12#certs.); |
| 365 | if (ret == 0) |
| 366 | *data = p12; |
| 367 | goto out; |
| 368 | } |
| 369 | |
| 370 | ret = rk_undumpdatacxx . . $ rk_undumpdata(27335df6773e97e0).(residue, &buf, &len); |
| 371 | if (ret) { |
| 372 | hx509_clear_error_stringcxx . . $ hx509_clear_error_string(54867dbb71d6169d).(context); |
| 373 | goto out; |
| 374 | } |
| 375 | |
| 376 | ret = decode_PKCS12_PFXcxx . . $ decode_PKCS12_PFX(c5861f4679372401).(buf, len, &pfx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 377 | rk_xfreecxx . . $ rk_xfree(5d22bdacc48458e8).(buf); |
| 378 | if (ret) { |
| 379 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, 0, ret, |
| 380 | "Failed to decode the PFX in %s", residue); |
| 381 | goto out; |
| 382 | } |
| 383 | |
| 384 | if (der_heim_oid_cmpcxx . . $ der_heim_oid_cmp(57bc20a77f38f7ca).(&pfx.authSafecxx . . $ PKCS12_PFX#authSafe..contentTypecxx . . $ ContentInfo#contentType., &asn1_oid_id_pkcs7_datacxx . . $ asn1_oid_id_pkcs7_data.) != 0) { |
| 385 | free_PKCS12_PFXcxx . . $ free_PKCS12_PFX(e49d29de9a2f26cd).(&pfx); |
| 386 | ret = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 387 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, 0, ret, |
| 388 | "PKCS PFX isn't a pkcs7-data container"); |
| 389 | goto out; |
| 390 | } |
| 391 | |
| 392 | if (pfx.authSafecxx . . $ PKCS12_PFX#authSafe..contentcxx . . $ ContentInfo#content. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 393 | free_PKCS12_PFXcxx . . $ free_PKCS12_PFX(e49d29de9a2f26cd).(&pfx); |
| 394 | ret = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; |
| 395 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, 0, ret, |
| 396 | "PKCS PFX missing data"); |
| 397 | goto out; |
| 398 | } |
| 399 | |
| 400 | { |
| 401 | heim_octet_stringcxx . . $ heim_octet_string# asdata; |
| 402 | |
| 403 | ret = decode_PKCS12_OctetStringcxx . . $ decode_PKCS12_OctetString(8d625750367953f9).(pfx.authSafecxx . . $ PKCS12_PFX#authSafe..contentcxx . . $ ContentInfo#content.->datacxx . . $ heim_base_data#data., |
| 404 | pfx.authSafecxx . . $ PKCS12_PFX#authSafe..contentcxx . . $ ContentInfo#content.->lengthcxx . . $ heim_base_data#length., |
| 405 | &asdata, |
| 406 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 407 | free_PKCS12_PFXcxx . . $ free_PKCS12_PFX(e49d29de9a2f26cd).(&pfx); |
| 408 | if (ret) { |
| 409 | hx509_clear_error_stringcxx . . $ hx509_clear_error_string(54867dbb71d6169d).(context); |
| 410 | goto out; |
| 411 | } |
| 412 | ret = decode_PKCS12_AuthenticatedSafecxx . . $ decode_PKCS12_AuthenticatedSafe(5f70339cf23dcce).(asdata.datacxx . . $ heim_base_data#data., |
| 413 | asdata.lengthcxx . . $ heim_base_data#length., |
| 414 | &as, |
| 415 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 416 | der_free_octet_stringcxx . . $ der_free_octet_string(8b8af749bc8ea7aa).(&asdata); |
| 417 | if (ret) { |
| 418 | hx509_clear_error_stringcxx . . $ hx509_clear_error_string(54867dbb71d6169d).(context); |
| 419 | goto out; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | for (i = 0; i < as.lencxx . . $ PKCS12_AuthenticatedSafe#len.; i++) |
| 424 | parse_pkcs12_typecxx . . $ parse_pkcs12_type(75323a9a1fd3dbf9).(context, |
| 425 | c, |
| 426 | &as.valcxx . . $ PKCS12_AuthenticatedSafe#val.[i].contentTypecxx . . $ ContentInfo#contentType., |
| 427 | as.valcxx . . $ PKCS12_AuthenticatedSafe#val.[i].contentcxx . . $ ContentInfo#content.->datacxx . . $ heim_base_data#data., |
| 428 | as.valcxx . . $ PKCS12_AuthenticatedSafe#val.[i].contentcxx . . $ ContentInfo#content.->lengthcxx . . $ heim_base_data#length., |
| 429 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 430 | |
| 431 | free_PKCS12_AuthenticatedSafecxx . . $ free_PKCS12_AuthenticatedSafe(bc82c18648ebdb35).(&as); |
| 432 | |
| 433 | ret = _hx509_collector_collect_certscxx . . $ _hx509_collector_collect_certs(1d56695ac015f9c3).(context, c, &p12->certscxx . . $ ks_pkcs12#certs.); |
| 434 | if (ret == 0) |
| 435 | *data = p12; |
| 436 | |
| 437 | out: |
| 438 | _hx509_collector_freecxx . . $ _hx509_collector_free(2b19c98744358106).(c); |
| 439 | |
| 440 | if (ret && p12) { |
| 441 | if (p12->fncxx . . $ ks_pkcs12#fn.) |
| 442 | freecxx . . $ free(5d22bdacc48458e8).(p12->fncxx . . $ ks_pkcs12#fn.); |
| 443 | if (p12->certscxx . . $ ks_pkcs12#certs.) |
| 444 | hx509_certs_freecxx . . $ hx509_certs_free(5dd004a9264d2921).(&p12->certscxx . . $ ks_pkcs12#certs.); |
| 445 | freecxx . . $ free(5d22bdacc48458e8).(p12); |
| 446 | } |
| 447 | |
| 448 | return ret; |
| 449 | } |
| 450 | |
| 451 | static int |
| 452 | addBagcxx . . $ addBag(40302b6ceba1c723).(hx509_contextcxx . . $ hx509_context# context, |
| 453 | PKCS12_AuthenticatedSafecxx . . $ PKCS12_AuthenticatedSafe# *as, |
| 454 | const heim_oidcxx . . $ heim_oid# *oid, |
| 455 | void *data, |
| 456 | size_t length) |
| 457 | { |
| 458 | void *ptr; |
| 459 | int ret; |
| 460 | |
| 461 | ptr = realloccxx . . $ realloc(417ab160f6baadc6).(as->valcxx . . $ PKCS12_AuthenticatedSafe#val., sizeof(as->valcxx . . $ PKCS12_AuthenticatedSafe#val.[0]) * (as->lencxx . . $ PKCS12_AuthenticatedSafe#len. + 1)); |
| 462 | if (ptr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 463 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, 0, ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!, "out of memory"); |
| 464 | return ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!; |
| 465 | } |
| 466 | as->valcxx . . $ PKCS12_AuthenticatedSafe#val. = ptr; |
| 467 | |
| 468 | ret = der_copy_oidcxx . . $ der_copy_oid(4c338c4d92787e68).(oid, &as->valcxx . . $ PKCS12_AuthenticatedSafe#val.[as->lencxx . . $ PKCS12_AuthenticatedSafe#len.].contentTypecxx . . $ ContentInfo#contentType.); |
| 469 | if (ret) { |
| 470 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, 0, ret, "out of memory"); |
| 471 | return ret; |
| 472 | } |
| 473 | |
| 474 | as->valcxx . . $ PKCS12_AuthenticatedSafe#val.[as->lencxx . . $ PKCS12_AuthenticatedSafe#len.].contentcxx . . $ ContentInfo#content. = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*as->valcxx . . $ PKCS12_AuthenticatedSafe#val.[0].contentcxx . . $ ContentInfo#content.)); |
| 475 | if (as->valcxx . . $ PKCS12_AuthenticatedSafe#val.[as->lencxx . . $ PKCS12_AuthenticatedSafe#len.].contentcxx . . $ ContentInfo#content. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!) { |
| 476 | der_free_oidcxx . . $ der_free_oid(99c92d7caa6f2cbd).(&as->valcxx . . $ PKCS12_AuthenticatedSafe#val.[as->lencxx . . $ PKCS12_AuthenticatedSafe#len.].contentTypecxx . . $ ContentInfo#contentType.); |
| 477 | hx509_set_error_stringcxx . . $ hx509_set_error_string(bd6d501f93232e20).(context, 0, ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!, "malloc out of memory"); |
| 478 | return ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!; |
| 479 | } |
| 480 | |
| 481 | as->valcxx . . $ PKCS12_AuthenticatedSafe#val.[as->lencxx . . $ PKCS12_AuthenticatedSafe#len.].contentcxx . . $ ContentInfo#content.->datacxx . . $ heim_base_data#data. = data; |
| 482 | as->valcxx . . $ PKCS12_AuthenticatedSafe#val.[as->lencxx . . $ PKCS12_AuthenticatedSafe#len.].contentcxx . . $ ContentInfo#content.->lengthcxx . . $ heim_base_data#length. = length; |
| 483 | |
| 484 | as->lencxx . . $ PKCS12_AuthenticatedSafe#len.++; |
| 485 | |
| 486 | return 0; |
| 487 | } |
| 488 | |
| 489 | static int |
| 490 | store_funccxx . . $ store_func(a2296146f562b407).(hx509_contextcxx . . $ hx509_context# context, void *ctx, hx509_certcxx . . $ hx509_cert# c) |
| 491 | { |
| 492 | PKCS12_AuthenticatedSafecxx . . $ PKCS12_AuthenticatedSafe# *as = ctx; |
| 493 | PKCS12_OctetStringcxx . . $ PKCS12_OctetString# os; |
| 494 | PKCS12_CertBagcxx . . $ PKCS12_CertBag# cb; |
| 495 | size_t size; |
| 496 | int ret; |
| 497 | |
| 498 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&os, 0, sizeof(os)); |
| 499 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&cb, 0, sizeof(cb)); |
| 500 | |
| 501 | os.datacxx . . $ heim_base_data#data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 502 | os.lengthcxx . . $ heim_base_data#length. = 0; |
| 503 | |
| 504 | ret = hx509_cert_binarycxx . . $ hx509_cert_binary(63ed7c6b5059d863).(context, c, &os); |
| 505 | if (ret) |
| 506 | return ret; |
| 507 | |
| 508 | ASN1_MALLOC_ENCODEcxx . . $ `include/rfc2459_asn1.h:61:9`!(PKCS12_OctetString, |
| 509 | cb.certValue.data,cb.certValue.length, |
| 510 | &os, &size, ret); |
| 511 | freecxx . . $ free(5d22bdacc48458e8).(os.datacxx . . $ heim_base_data#data.); |
| 512 | if (ret) |
| 513 | goto out; |
| 514 | ret = der_copy_oidcxx . . $ der_copy_oid(4c338c4d92787e68).(&asn1_oid_id_pkcs_9_at_certTypes_x509cxx . . $ asn1_oid_id_pkcs_9_at_certTypes_x509., &cb.certTypecxx . . $ PKCS12_CertBag#certType.); |
| 515 | if (ret) { |
| 516 | free_PKCS12_CertBagcxx . . $ free_PKCS12_CertBag(8b44870e99893800).(&cb); |
| 517 | goto out; |
| 518 | } |
| 519 | ASN1_MALLOC_ENCODEcxx . . $ `include/rfc2459_asn1.h:61:9`!(PKCS12_CertBag, os.data, os.length, |
| 520 | &cb, &size, ret); |
| 521 | free_PKCS12_CertBagcxx . . $ free_PKCS12_CertBag(8b44870e99893800).(&cb); |
| 522 | if (ret) |
| 523 | goto out; |
| 524 | |
| 525 | ret = addBagcxx . . $ addBag(40302b6ceba1c723).(context, as, &asn1_oid_id_pkcs12_certBagcxx . . $ asn1_oid_id_pkcs12_certBag., os.datacxx . . $ heim_base_data#data., os.lengthcxx . . $ heim_base_data#length.); |
| 526 | |
| 527 | if (_hx509_cert_private_key_exportablecxx . . $ _hx509_cert_private_key_exportable(18eb62ea1346ccdb).(c)) { |
| 528 | hx509_private_keycxx . . $ hx509_private_key# key = _hx509_cert_private_keycxx . . $ _hx509_cert_private_key(a20e713bb9af5ac5).(c); |
| 529 | PKCS8PrivateKeyInfocxx . . $ PKCS8PrivateKeyInfo# pki; |
| 530 | |
| 531 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&pki, 0, sizeof(pki)); |
| 532 | |
| 533 | ret = der_parse_hex_heim_integercxx . . $ der_parse_hex_heim_integer(96e843b0accadac6).("00", &pki.versioncxx . . $ PKCS8PrivateKeyInfo#version.); |
| 534 | if (ret) |
| 535 | return ret; |
| 536 | ret = _hx509_private_key_oidcxx . . $ _hx509_private_key_oid(21f60c0ca8c4c72).(context, key, |
| 537 | &pki.privateKeyAlgorithmcxx . . $ PKCS8PrivateKeyInfo#privateKeyAlgorithm..algorithmcxx . . $ AlgorithmIdentifier#algorithm.); |
| 538 | if (ret) { |
| 539 | free_PKCS8PrivateKeyInfocxx . . $ free_PKCS8PrivateKeyInfo(ab6518dd27c45d78).(&pki); |
| 540 | return ret; |
| 541 | } |
| 542 | ret = _hx509_private_key_exportcxx . . $ _hx509_private_key_export(cde61fec2b1d2fcf).(context, |
| 543 | _hx509_cert_private_keycxx . . $ _hx509_cert_private_key(a20e713bb9af5ac5).(c), |
| 544 | HX509_KEY_FORMAT_DERcxx . . $ HX509_KEY_FORMAT_DER., |
| 545 | &pki.privateKeycxx . . $ PKCS8PrivateKeyInfo#privateKey.); |
| 546 | if (ret) { |
| 547 | free_PKCS8PrivateKeyInfocxx . . $ free_PKCS8PrivateKeyInfo(ab6518dd27c45d78).(&pki); |
| 548 | return ret; |
| 549 | } |
| 550 | /* set attribute, asn1_oid_id_pkcs_9_at_localKeyId */ |
| 551 | |
| 552 | ASN1_MALLOC_ENCODEcxx . . $ `include/rfc2459_asn1.h:61:9`!(PKCS8PrivateKeyInfo, os.data, os.length, |
| 553 | &pki, &size, ret); |
| 554 | free_PKCS8PrivateKeyInfocxx . . $ free_PKCS8PrivateKeyInfo(ab6518dd27c45d78).(&pki); |
| 555 | if (ret) |
| 556 | return ret; |
| 557 | |
| 558 | ret = addBagcxx . . $ addBag(40302b6ceba1c723).(context, as, &asn1_oid_id_pkcs12_keyBagcxx . . $ asn1_oid_id_pkcs12_keyBag., os.datacxx . . $ heim_base_data#data., os.lengthcxx . . $ heim_base_data#length.); |
| 559 | if (ret) |
| 560 | return ret; |
| 561 | } |
| 562 | |
| 563 | out: |
| 564 | return ret; |
| 565 | } |
| 566 | |
| 567 | static int |
| 568 | p12_storecxx . . $ p12_store(44929cf4e3fb061f).(hx509_contextcxx . . $ hx509_context# context, |
| 569 | hx509_certscxx . . $ hx509_certs# certs, void *data, int flags, hx509_lockcxx . . $ hx509_lock# lock) |
| 570 | { |
| 571 | struct ks_pkcs12cxx . . $ ks_pkcs12# *p12 = data; |
| 572 | PKCS12_PFXcxx . . $ PKCS12_PFX# pfx; |
| 573 | PKCS12_AuthenticatedSafecxx . . $ PKCS12_AuthenticatedSafe# as; |
| 574 | PKCS12_OctetStringcxx . . $ PKCS12_OctetString# asdata; |
| 575 | size_t size; |
| 576 | int ret; |
| 577 | |
| 578 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&as, 0, sizeof(as)); |
| 579 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&pfx, 0, sizeof(pfx)); |
| 580 | |
| 581 | ret = hx509_certs_iter_fcxx . . $ hx509_certs_iter_f(e64360f286fa569c).(context, p12->certscxx . . $ ks_pkcs12#certs., store_funccxx . . $ store_func(a2296146f562b407)., &as); |
| 582 | if (ret) |
| 583 | goto out; |
| 584 | |
| 585 | ASN1_MALLOC_ENCODEcxx . . $ `include/rfc2459_asn1.h:61:9`!(PKCS12_AuthenticatedSafe, asdata.data, asdata.length, |
| 586 | &as, &size, ret); |
| 587 | free_PKCS12_AuthenticatedSafecxx . . $ free_PKCS12_AuthenticatedSafe(bc82c18648ebdb35).(&as); |
| 588 | if (ret) |
| 589 | return ret; |
| 590 | |
| 591 | ret = der_parse_hex_heim_integercxx . . $ der_parse_hex_heim_integer(96e843b0accadac6).("03", &pfx.versioncxx . . $ PKCS12_PFX#version.); |
| 592 | if (ret) { |
| 593 | freecxx . . $ free(5d22bdacc48458e8).(asdata.datacxx . . $ heim_base_data#data.); |
| 594 | goto out; |
| 595 | } |
| 596 | |
| 597 | pfx.authSafecxx . . $ PKCS12_PFX#authSafe..contentcxx . . $ ContentInfo#content. = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*pfx.authSafecxx . . $ PKCS12_PFX#authSafe..contentcxx . . $ ContentInfo#content.)); |
| 598 | |
| 599 | ASN1_MALLOC_ENCODEcxx . . $ `include/rfc2459_asn1.h:61:9`!(PKCS12_OctetString, |
| 600 | pfx.authSafe.content->data, |
| 601 | pfx.authSafe.content->length, |
| 602 | &asdata, &size, ret); |
| 603 | freecxx . . $ free(5d22bdacc48458e8).(asdata.datacxx . . $ heim_base_data#data.); |
| 604 | if (ret) |
| 605 | goto out; |
| 606 | |
| 607 | ret = der_copy_oidcxx . . $ der_copy_oid(4c338c4d92787e68).(&asn1_oid_id_pkcs7_datacxx . . $ asn1_oid_id_pkcs7_data., &pfx.authSafecxx . . $ PKCS12_PFX#authSafe..contentTypecxx . . $ ContentInfo#contentType.); |
| 608 | if (ret) |
| 609 | goto out; |
| 610 | |
| 611 | ASN1_MALLOC_ENCODEcxx . . $ `include/rfc2459_asn1.h:61:9`!(PKCS12_PFX, asdata.data, asdata.length, |
| 612 | &pfx, &size, ret); |
| 613 | if (ret) |
| 614 | goto out; |
| 615 | |
| 616 | #if 0 |
| 617 | const struct _hx509_password *pw; |
| 618 | |
| 619 | pw = _hx509_lock_get_passwords(lock); |
| 620 | if (pw != NULL) { |
| 621 | pfx.macData = calloc(1, sizeof(*pfx.macData)); |
| 622 | if (pfx.macData == NULL) { |
| 623 | ret = ENOMEM; |
| 624 | hx509_set_error_string(context, 0, ret, "malloc out of memory"); |
| 625 | return ret; |
| 626 | } |
| 627 | if (pfx.macData == NULL) { |
| 628 | free(asdata.data); |
| 629 | goto out; |
| 630 | } |
| 631 | } |
| 632 | ret = calculate_hash(&aspath, pw, pfx.macData); |
| 633 | #endif |
| 634 | |
| 635 | rk_dumpdatacxx . . $ rk_dumpdata(4a44491c447ebd93).(p12->fncxx . . $ ks_pkcs12#fn., asdata.datacxx . . $ heim_base_data#data., asdata.lengthcxx . . $ heim_base_data#length.); |
| 636 | freecxx . . $ free(5d22bdacc48458e8).(asdata.datacxx . . $ heim_base_data#data.); |
| 637 | |
| 638 | out: |
| 639 | free_PKCS12_AuthenticatedSafecxx . . $ free_PKCS12_AuthenticatedSafe(bc82c18648ebdb35).(&as); |
| 640 | free_PKCS12_PFXcxx . . $ free_PKCS12_PFX(e49d29de9a2f26cd).(&pfx); |
| 641 | |
| 642 | return ret; |
| 643 | } |
| 644 | |
| 645 | |
| 646 | static int |
| 647 | p12_freecxx . . $ p12_free(18e6780d0262d322).(hx509_certscxx . . $ hx509_certs# certs, void *data) |
| 648 | { |
| 649 | struct ks_pkcs12cxx . . $ ks_pkcs12# *p12 = data; |
| 650 | hx509_certs_freecxx . . $ hx509_certs_free(5dd004a9264d2921).(&p12->certscxx . . $ ks_pkcs12#certs.); |
| 651 | freecxx . . $ free(5d22bdacc48458e8).(p12->fncxx . . $ ks_pkcs12#fn.); |
| 652 | freecxx . . $ free(5d22bdacc48458e8).(p12); |
| 653 | return 0; |
| 654 | } |
| 655 | |
| 656 | static int |
| 657 | p12_addcxx . . $ p12_add(7db12cc113e2b10f).(hx509_contextcxx . . $ hx509_context# context, hx509_certscxx . . $ hx509_certs# certs, void *data, hx509_certcxx . . $ hx509_cert# c) |
| 658 | { |
| 659 | struct ks_pkcs12cxx . . $ ks_pkcs12# *p12 = data; |
| 660 | return hx509_certs_addcxx . . $ hx509_certs_add(90bc25667e531ba0).(context, p12->certscxx . . $ ks_pkcs12#certs., c); |
| 661 | } |
| 662 | |
| 663 | static int |
| 664 | p12_iter_startcxx . . $ p12_iter_start(99af47b82533a8e0).(hx509_contextcxx . . $ hx509_context# context, |
| 665 | hx509_certscxx . . $ hx509_certs# certs, |
| 666 | void *data, |
| 667 | void **cursor) |
| 668 | { |
| 669 | struct ks_pkcs12cxx . . $ ks_pkcs12# *p12 = data; |
| 670 | return hx509_certs_start_seqcxx . . $ hx509_certs_start_seq(75da60395aa3d685).(context, p12->certscxx . . $ ks_pkcs12#certs., cursor); |
| 671 | } |
| 672 | |
| 673 | static int |
| 674 | p12_itercxx . . $ p12_iter(cad85e8772a144a6).(hx509_contextcxx . . $ hx509_context# context, |
| 675 | hx509_certscxx . . $ hx509_certs# certs, |
| 676 | void *data, |
| 677 | void *cursor, |
| 678 | hx509_certcxx . . $ hx509_cert# *cert) |
| 679 | { |
| 680 | struct ks_pkcs12cxx . . $ ks_pkcs12# *p12 = data; |
| 681 | return hx509_certs_next_certcxx . . $ hx509_certs_next_cert(753edddbbe48e15a).(context, p12->certscxx . . $ ks_pkcs12#certs., cursor, cert); |
| 682 | } |
| 683 | |
| 684 | static int |
| 685 | p12_iter_endcxx . . $ p12_iter_end(c6690855a566acb7).(hx509_contextcxx . . $ hx509_context# context, |
| 686 | hx509_certscxx . . $ hx509_certs# certs, |
| 687 | void *data, |
| 688 | void *cursor) |
| 689 | { |
| 690 | struct ks_pkcs12cxx . . $ ks_pkcs12# *p12 = data; |
| 691 | return hx509_certs_end_seqcxx . . $ hx509_certs_end_seq(7ba52348774ec517).(context, p12->certscxx . . $ ks_pkcs12#certs., cursor); |
| 692 | } |
| 693 | |
| 694 | static struct hx509_keyset_opscxx . . $ hx509_keyset_ops# keyset_pkcs12cxx . . $ keyset_pkcs12. = { |
| 695 | "PKCS12", |
| 696 | 0, |
| 697 | p12_initcxx . . $ p12_init(b8c8de8f8ec1b894)., |
| 698 | p12_storecxx . . $ p12_store(44929cf4e3fb061f)., |
| 699 | p12_freecxx . . $ p12_free(18e6780d0262d322)., |
| 700 | p12_addcxx . . $ p12_add(7db12cc113e2b10f)., |
| 701 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 702 | p12_iter_startcxx . . $ p12_iter_start(99af47b82533a8e0)., |
| 703 | p12_itercxx . . $ p12_iter(cad85e8772a144a6)., |
| 704 | p12_iter_endcxx . . $ p12_iter_end(c6690855a566acb7)., |
| 705 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 706 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 707 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! |
| 708 | }; |
| 709 | |
| 710 | void |
| 711 | _hx509_ks_pkcs12_registercxx . . $ _hx509_ks_pkcs12_register(54867dbb71d6169d).(hx509_contextcxx . . $ hx509_context# context) |
| 712 | { |
| 713 | _hx509_ks_registercxx . . $ _hx509_ks_register(a9b934d8821b5346).(context, &keyset_pkcs12cxx . . $ keyset_pkcs12.); |
| 714 | } |