engine/e_capi.c: more formatting and styling fixes.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 8f0e5888ea4c577c5a1f0d667786da6376099c86)
Andy Polyakov
7 years ago
107 | 107 | static void capi_addlasterror(void); |
108 | 108 | static void capi_adderror(DWORD err); |
109 | 109 | |
110 | static void CAPI_trace(CAPI_CTX * ctx, char *format, ...); | |
111 | ||
112 | static int capi_list_providers(CAPI_CTX * ctx, BIO *out); | |
113 | static int capi_list_containers(CAPI_CTX * ctx, BIO *out); | |
114 | int capi_list_certs(CAPI_CTX * ctx, BIO *out, char *storename); | |
115 | void capi_free_key(CAPI_KEY * key); | |
116 | ||
117 | static PCCERT_CONTEXT capi_find_cert(CAPI_CTX * ctx, const char *id, | |
110 | static void CAPI_trace(CAPI_CTX *ctx, char *format, ...); | |
111 | ||
112 | static int capi_list_providers(CAPI_CTX *ctx, BIO *out); | |
113 | static int capi_list_containers(CAPI_CTX *ctx, BIO *out); | |
114 | int capi_list_certs(CAPI_CTX *ctx, BIO *out, char *storename); | |
115 | void capi_free_key(CAPI_KEY *key); | |
116 | ||
117 | static PCCERT_CONTEXT capi_find_cert(CAPI_CTX *ctx, const char *id, | |
118 | 118 | HCERTSTORE hstore); |
119 | 119 | |
120 | CAPI_KEY *capi_find_key(CAPI_CTX * ctx, const char *id); | |
120 | CAPI_KEY *capi_find_key(CAPI_CTX *ctx, const char *id); | |
121 | 121 | |
122 | 122 | static EVP_PKEY *capi_load_privkey(ENGINE *eng, const char *key_id, |
123 | 123 | UI_METHOD *ui_method, void *callback_data); |
192 | 192 | }; |
193 | 193 | |
194 | 194 | static CAPI_CTX *capi_ctx_new(void); |
195 | static void capi_ctx_free(CAPI_CTX * ctx); | |
196 | static int capi_ctx_set_provname(CAPI_CTX * ctx, LPSTR pname, DWORD type, | |
195 | static void capi_ctx_free(CAPI_CTX *ctx); | |
196 | static int capi_ctx_set_provname(CAPI_CTX *ctx, LPSTR pname, DWORD type, | |
197 | 197 | int check); |
198 | static int capi_ctx_set_provname_idx(CAPI_CTX * ctx, int idx); | |
198 | static int capi_ctx_set_provname_idx(CAPI_CTX *ctx, int idx); | |
199 | 199 | |
200 | 200 | # define CAPI_CMD_LIST_CERTS ENGINE_CMD_BASE |
201 | 201 | # define CAPI_CMD_LOOKUP_CERT (ENGINE_CMD_BASE + 1) |
621 | 621 | |
622 | 622 | /* Given a CAPI_KEY get an EVP_PKEY structure */ |
623 | 623 | |
624 | static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY * key) | |
624 | static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY *key) | |
625 | 625 | { |
626 | 626 | unsigned char *pubkey = NULL; |
627 | 627 | DWORD len; |
1049 | 1049 | } |
1050 | 1050 | # endif |
1051 | 1051 | |
1052 | static void capi_vtrace(CAPI_CTX * ctx, int level, char *format, | |
1052 | static void capi_vtrace(CAPI_CTX *ctx, int level, char *format, | |
1053 | 1053 | va_list argptr) |
1054 | 1054 | { |
1055 | 1055 | BIO *out; |
1065 | 1065 | BIO_free(out); |
1066 | 1066 | } |
1067 | 1067 | |
1068 | static void CAPI_trace(CAPI_CTX * ctx, char *format, ...) | |
1068 | static void CAPI_trace(CAPI_CTX *ctx, char *format, ...) | |
1069 | 1069 | { |
1070 | 1070 | va_list args; |
1071 | 1071 | va_start(args, format); |
1111 | 1111 | return str; |
1112 | 1112 | } |
1113 | 1113 | |
1114 | static int capi_get_provname(CAPI_CTX * ctx, LPSTR * pname, DWORD * ptype, | |
1114 | static int capi_get_provname(CAPI_CTX *ctx, LPSTR *pname, DWORD *ptype, | |
1115 | 1115 | DWORD idx) |
1116 | 1116 | { |
1117 | 1117 | DWORD len, err; |
1153 | 1153 | return 1; |
1154 | 1154 | } |
1155 | 1155 | |
1156 | static int capi_list_providers(CAPI_CTX * ctx, BIO *out) | |
1156 | static int capi_list_providers(CAPI_CTX *ctx, BIO *out) | |
1157 | 1157 | { |
1158 | 1158 | DWORD idx, ptype; |
1159 | 1159 | int ret; |
1172 | 1172 | return 1; |
1173 | 1173 | } |
1174 | 1174 | |
1175 | static int capi_list_containers(CAPI_CTX * ctx, BIO *out) | |
1175 | static int capi_list_containers(CAPI_CTX *ctx, BIO *out) | |
1176 | 1176 | { |
1177 | 1177 | int ret = 1; |
1178 | 1178 | HCRYPTPROV hprov; |
1256 | 1256 | return ret; |
1257 | 1257 | } |
1258 | 1258 | |
1259 | static CRYPT_KEY_PROV_INFO *capi_get_prov_info(CAPI_CTX * ctx, | |
1259 | static CRYPT_KEY_PROV_INFO *capi_get_prov_info(CAPI_CTX *ctx, | |
1260 | 1260 | PCCERT_CONTEXT cert) |
1261 | 1261 | { |
1262 | 1262 | DWORD len; |
1281 | 1281 | return pinfo; |
1282 | 1282 | } |
1283 | 1283 | |
1284 | static void capi_dump_prov_info(CAPI_CTX * ctx, BIO *out, | |
1285 | CRYPT_KEY_PROV_INFO * pinfo) | |
1284 | static void capi_dump_prov_info(CAPI_CTX *ctx, BIO *out, | |
1285 | CRYPT_KEY_PROV_INFO *pinfo) | |
1286 | 1286 | { |
1287 | 1287 | char *provname = NULL, *contname = NULL; |
1288 | 1288 | if (!pinfo) { |
1304 | 1304 | OPENSSL_free(contname); |
1305 | 1305 | } |
1306 | 1306 | |
1307 | static char *capi_cert_get_fname(CAPI_CTX * ctx, PCCERT_CONTEXT cert) | |
1307 | static char *capi_cert_get_fname(CAPI_CTX *ctx, PCCERT_CONTEXT cert) | |
1308 | 1308 | { |
1309 | 1309 | LPWSTR wfname; |
1310 | 1310 | DWORD dlen; |
1329 | 1329 | return NULL; |
1330 | 1330 | } |
1331 | 1331 | |
1332 | static void capi_dump_cert(CAPI_CTX * ctx, BIO *out, PCCERT_CONTEXT cert) | |
1332 | static void capi_dump_cert(CAPI_CTX *ctx, BIO *out, PCCERT_CONTEXT cert) | |
1333 | 1333 | { |
1334 | 1334 | X509 *x; |
1335 | 1335 | const unsigned char *p; |
1371 | 1371 | X509_free(x); |
1372 | 1372 | } |
1373 | 1373 | |
1374 | static HCERTSTORE capi_open_store(CAPI_CTX * ctx, char *storename) | |
1374 | static HCERTSTORE capi_open_store(CAPI_CTX *ctx, char *storename) | |
1375 | 1375 | { |
1376 | 1376 | HCERTSTORE hstore; |
1377 | 1377 | |
1390 | 1390 | return hstore; |
1391 | 1391 | } |
1392 | 1392 | |
1393 | int capi_list_certs(CAPI_CTX * ctx, BIO *out, char *id) | |
1393 | int capi_list_certs(CAPI_CTX *ctx, BIO *out, char *id) | |
1394 | 1394 | { |
1395 | 1395 | char *storename; |
1396 | 1396 | int idx; |
1428 | 1428 | return ret; |
1429 | 1429 | } |
1430 | 1430 | |
1431 | static PCCERT_CONTEXT capi_find_cert(CAPI_CTX * ctx, const char *id, | |
1431 | static PCCERT_CONTEXT capi_find_cert(CAPI_CTX *ctx, const char *id, | |
1432 | 1432 | HCERTSTORE hstore) |
1433 | 1433 | { |
1434 | 1434 | PCCERT_CONTEXT cert = NULL; |
1459 | 1459 | } |
1460 | 1460 | } |
1461 | 1461 | |
1462 | static CAPI_KEY *capi_get_key(CAPI_CTX * ctx, const TCHAR *contname, | |
1462 | static CAPI_KEY *capi_get_key(CAPI_CTX *ctx, const TCHAR *contname, | |
1463 | 1463 | TCHAR *provname, DWORD ptype, DWORD keyspec) |
1464 | 1464 | { |
1465 | 1465 | DWORD dwFlags = 0; |
1507 | 1507 | return NULL; |
1508 | 1508 | } |
1509 | 1509 | |
1510 | static CAPI_KEY *capi_get_cert_key(CAPI_CTX * ctx, PCCERT_CONTEXT cert) | |
1510 | static CAPI_KEY *capi_get_cert_key(CAPI_CTX *ctx, PCCERT_CONTEXT cert) | |
1511 | 1511 | { |
1512 | 1512 | CAPI_KEY *key = NULL; |
1513 | 1513 | CRYPT_KEY_PROV_INFO *pinfo = NULL; |
1535 | 1535 | return key; |
1536 | 1536 | } |
1537 | 1537 | |
1538 | CAPI_KEY *capi_find_key(CAPI_CTX * ctx, const char *id) | |
1538 | CAPI_KEY *capi_find_key(CAPI_CTX *ctx, const char *id) | |
1539 | 1539 | { |
1540 | 1540 | PCCERT_CONTEXT cert; |
1541 | 1541 | HCERTSTORE hstore; |
1579 | 1579 | return key; |
1580 | 1580 | } |
1581 | 1581 | |
1582 | void capi_free_key(CAPI_KEY * key) | |
1582 | void capi_free_key(CAPI_KEY *key) | |
1583 | 1583 | { |
1584 | 1584 | if (!key) |
1585 | 1585 | return; |
1610 | 1610 | return ctx; |
1611 | 1611 | } |
1612 | 1612 | |
1613 | static void capi_ctx_free(CAPI_CTX * ctx) | |
1613 | static void capi_ctx_free(CAPI_CTX *ctx) | |
1614 | 1614 | { |
1615 | 1615 | CAPI_trace(ctx, "Calling capi_ctx_free with %lx\n", ctx); |
1616 | 1616 | if (!ctx) |
1622 | 1622 | OPENSSL_free(ctx); |
1623 | 1623 | } |
1624 | 1624 | |
1625 | static int capi_ctx_set_provname(CAPI_CTX * ctx, LPSTR pname, DWORD type, | |
1625 | static int capi_ctx_set_provname(CAPI_CTX *ctx, LPSTR pname, DWORD type, | |
1626 | 1626 | int check) |
1627 | 1627 | { |
1628 | 1628 | LPSTR tmpcspname; |
1661 | 1661 | return 1; |
1662 | 1662 | } |
1663 | 1663 | |
1664 | static int capi_ctx_set_provname_idx(CAPI_CTX * ctx, int idx) | |
1664 | static int capi_ctx_set_provname_idx(CAPI_CTX *ctx, int idx) | |
1665 | 1665 | { |
1666 | 1666 | LPSTR pname; |
1667 | 1667 | DWORD type; |