Lines Matching defs:sp

145 static CK_OBJECT_HANDLE pk11_get_public_rsa_key(RSA* rsa, PK11_SESSION *sp);
146 static CK_OBJECT_HANDLE pk11_get_private_rsa_key(RSA* rsa, PK11_SESSION *sp);
148 static int pk11_check_new_rsa_key_pub(PK11_SESSION *sp, const RSA *rsa);
149 static int pk11_check_new_rsa_key_priv(PK11_SESSION *sp, const RSA *rsa);
166 static int check_new_dsa_key_pub(PK11_SESSION *sp, DSA *dsa);
167 static int check_new_dsa_key_priv(PK11_SESSION *sp, DSA *dsa);
181 static int check_new_dh_key(PK11_SESSION *sp, DH *dh);
732 PK11_SESSION *sp;
734 if ((sp = pk11_get_session(OP_RSA)) == NULL) {
738 (void) pk11_check_new_rsa_key_pub(sp, rsa);
740 h_pub_key = sp->opdata_rsa_pub_key;
742 h_pub_key = sp->opdata_rsa_pub_key =
743 pk11_get_public_rsa_key(rsa, sp);
747 rv = pFuncList->C_EncryptInit(sp->session, p_mech,
752 pk11_return_session(sp, OP_RSA);
756 rv = pFuncList->C_Encrypt(sp->session,
761 pk11_return_session(sp, OP_RSA);
767 pk11_return_session(sp, OP_RSA);
787 PK11_SESSION *sp;
789 if ((sp = pk11_get_session(OP_RSA)) == NULL) {
793 (void) pk11_check_new_rsa_key_priv(sp, rsa);
795 h_priv_key = sp->opdata_rsa_priv_key;
797 h_priv_key = sp->opdata_rsa_priv_key =
798 pk11_get_private_rsa_key(rsa, sp);
802 rv = pFuncList->C_SignInit(sp->session, p_mech,
808 pk11_return_session(sp, OP_RSA);
812 rv = pFuncList->C_Sign(sp->session,
817 pk11_return_session(sp, OP_RSA);
824 pk11_return_session(sp, OP_RSA);
844 PK11_SESSION *sp;
846 if ((sp = pk11_get_session(OP_RSA)) == NULL) {
850 (void) pk11_check_new_rsa_key_priv(sp, rsa);
852 h_priv_key = sp->opdata_rsa_priv_key;
854 h_priv_key = sp->opdata_rsa_priv_key =
855 pk11_get_private_rsa_key(rsa, sp);
859 rv = pFuncList->C_DecryptInit(sp->session, p_mech,
865 pk11_return_session(sp, OP_RSA);
869 rv = pFuncList->C_Decrypt(sp->session,
875 pk11_return_session(sp, OP_RSA);
881 pk11_return_session(sp, OP_RSA);
901 PK11_SESSION *sp;
903 if ((sp = pk11_get_session(OP_RSA)) == NULL) {
907 (void) pk11_check_new_rsa_key_pub(sp, rsa);
909 h_pub_key = sp->opdata_rsa_pub_key;
911 h_pub_key = sp->opdata_rsa_pub_key =
912 pk11_get_public_rsa_key(rsa, sp);
916 rv = pFuncList->C_VerifyRecoverInit(sp->session,
922 pk11_return_session(sp, OP_RSA);
926 rv = pFuncList->C_VerifyRecover(sp->session,
931 pk11_return_session(sp, OP_RSA);
937 pk11_return_session(sp, OP_RSA);
993 PK11_SESSION *sp = NULL;
1047 if ((sp = pk11_get_session(OP_RSA)) == NULL) {
1051 (void) pk11_check_new_rsa_key_priv(sp, rsa);
1053 h_priv_key = sp->opdata_rsa_priv_key;
1055 h_priv_key = sp->opdata_rsa_priv_key =
1056 pk11_get_private_rsa_key((RSA *)rsa, sp);
1060 rv = pFuncList->C_SignInit(sp->session, p_mech, h_priv_key);
1067 rv = pFuncList->C_Sign(sp->session, s, i, sigret,
1084 pk11_return_session(sp, OP_RSA);
1103 PK11_SESSION *sp = NULL;
1154 if ((sp = pk11_get_session(OP_RSA)) == NULL) {
1158 (void) pk11_check_new_rsa_key_pub(sp, rsa);
1160 h_pub_key = sp->opdata_rsa_pub_key;
1162 h_pub_key = sp->opdata_rsa_pub_key =
1163 pk11_get_public_rsa_key((RSA *)rsa, sp);
1167 rv = pFuncList->C_VerifyInit(sp->session, p_mech,
1174 rv = pFuncList->C_Verify(sp->session, s, i,
1189 pk11_return_session(sp, OP_RSA);
1199 common_get_key_from_file(PK11_SESSION *sp, const char *keyid,
1240 (void) pk11_check_new_rsa_key_priv(sp, rsa);
1241 h_key = sp->opdata_rsa_priv_key =
1242 pk11_get_private_rsa_key(rsa, sp);
1244 (void) pk11_check_new_rsa_key_pub(sp, rsa);
1245 h_key = sp->opdata_rsa_pub_key =
1246 pk11_get_public_rsa_key(rsa, sp);
1271 common_get_key_from_token(ENGINE *e, PK11_SESSION *sp,
1308 if (pk11_token_login(sp->session, &pk11_login_done,
1317 if (find_one_object(OP_RSA, sp->session, search_templ, 3,
1333 * case of failure the sp structure will have both key pointer
1338 (void) pk11_destroy_rsa_object_priv(sp, CK_TRUE);
1339 sp->opdata_rsa_priv_key = ks_key;
1341 sp->persistent = CK_TRUE;
1342 rsa = sp->opdata_rsa_priv = RSA_new_method(e);
1344 (void) pk11_destroy_rsa_object_pub(sp, CK_TRUE);
1345 sp->opdata_rsa_pub_key = ks_key;
1346 rsa = sp->opdata_rsa_pub = RSA_new_method(e);
1352 if ((rv = pFuncList->C_GetAttributeValue(sp->session, ks_key,
1362 sp->opdata_rsa_priv = rsa;
1364 sp->opdata_rsa_pub = rsa;
1377 attr_to_BN(&get_templ[0], attr_data[0], &sp->opdata_rsa_n_num);
1378 attr_to_BN(&get_templ[1], attr_data[1], &sp->opdata_rsa_e_num);
1409 h_pub_key = sp->opdata_rsa_pub_key =
1410 pk11_get_public_rsa_key(rsa, sp);
1422 sp->opdata_rsa_priv = NULL;
1423 sp->opdata_rsa_pub = NULL;
1440 PK11_SESSION *sp;
1444 if ((sp = pk11_get_session(OP_RSA)) == NULL) {
1457 pkey = common_get_key_from_token(e, sp, &uri_struct,
1461 pkey = common_get_key_from_file(sp, keyid, is_private);
1467 pk11_return_session(sp, OP_RSA);
1499 * We use the session field from sp, and we cache rsa->(n|e) in
1503 pk11_get_public_rsa_key(RSA* rsa, PK11_SESSION *sp)
1551 rv = pFuncList->C_FindObjectsInit(sp->session, a_key_template,
1559 rv = pFuncList->C_FindObjects(sp->session, &h_key, 1, &found);
1566 rv = pFuncList->C_FindObjectsFinal(sp->session);
1574 rv = pFuncList->C_CreateObject(sp->session,
1583 if ((sp->opdata_rsa_n_num = BN_dup(rsa->n)) == NULL) {
1589 if ((sp->opdata_rsa_e_num = BN_dup(rsa->e)) == NULL) {
1591 BN_free(sp->opdata_rsa_n_num);
1592 sp->opdata_rsa_n_num = NULL;
1599 sp->opdata_rsa_pub = rsa;
1608 (void) pFuncList->C_DestroyObject(sp->session, h_key);
1633 pk11_get_private_rsa_key(RSA* rsa, PK11_SESSION *sp)
1705 rv = pFuncList->C_FindObjectsInit(sp->session, a_key_template,
1713 rv = pFuncList->C_FindObjects(sp->session, &h_key, 1, &found);
1720 rv = pFuncList->C_FindObjectsFinal(sp->session);
1741 rv = pFuncList->C_CreateObject(sp->session,
1760 if ((sp->opdata_rsa_d_num = BN_dup(rsa->d)) == NULL) {
1766 sp->opdata_rsa_d_num = NULL;
1774 if ((sp->opdata_rsa_n_num = BN_dup(rsa->n)) == NULL) {
1776 sp->opdata_rsa_n_num = NULL;
1780 if ((sp->opdata_rsa_e_num = BN_dup(rsa->e)) == NULL) {
1782 BN_free(sp->opdata_rsa_n_num);
1783 sp->opdata_rsa_n_num = NULL;
1790 sp->opdata_rsa_priv = rsa;
1799 (void) pFuncList->C_DestroyObject(sp->session, h_key);
1829 pk11_check_new_rsa_key_pub(PK11_SESSION *sp, const RSA *rsa)
1843 if (sp->opdata_rsa_pub == rsa &&
1844 BN_cmp(sp->opdata_rsa_n_num, rsa->n) == 0 &&
1845 BN_cmp(sp->opdata_rsa_e_num, rsa->e) == 0) {
1846 if (sp->opdata_rsa_pub_key != CK_INVALID_HANDLE) {
1863 (void) pk11_destroy_rsa_object_pub(sp, CK_TRUE);
1864 (void) pk11_destroy_rsa_object_priv(sp, CK_TRUE);
1874 pk11_check_new_rsa_key_priv(PK11_SESSION *sp, const RSA *rsa)
1885 if (sp->opdata_rsa_priv == rsa &&
1886 BN_cmp(sp->opdata_rsa_n_num, rsa->n) == 0 &&
1887 BN_cmp(sp->opdata_rsa_e_num, rsa->e) == 0) {
1888 if (sp->opdata_rsa_priv_key != CK_INVALID_HANDLE) {
1905 (void) pk11_destroy_rsa_object_priv(sp, CK_TRUE);
1906 (void) pk11_destroy_rsa_object_pub(sp, CK_TRUE);
1948 PK11_SESSION *sp = NULL;
1961 if ((sp = pk11_get_session(OP_DSA)) == NULL) {
1965 (void) check_new_dsa_key_priv(sp, dsa);
1967 h_priv_key = sp->opdata_dsa_priv_key;
1969 h_priv_key = sp->opdata_dsa_priv_key =
1971 &sp->opdata_dsa_priv,
1972 &sp->opdata_dsa_priv_num, sp->session);
1976 rv = pFuncList->C_SignInit(sp->session, p_mech, h_priv_key);
1983 rv = pFuncList->C_Sign(sp->session, (unsigned char *) dgst,
2025 pk11_return_session(sp, OP_DSA);
2044 PK11_SESSION *sp = NULL;
2066 if ((sp = pk11_get_session(OP_DSA)) == NULL) {
2070 (void) check_new_dsa_key_pub(sp, dsa);
2072 h_pub_key = sp->opdata_dsa_pub_key;
2074 h_pub_key = sp->opdata_dsa_pub_key =
2075 pk11_get_public_dsa_key((DSA *)dsa, &sp->opdata_dsa_pub,
2076 &sp->opdata_dsa_pub_num, sp->session);
2080 rv = pFuncList->C_VerifyInit(sp->session, p_mech, h_pub_key);
2097 rv = pFuncList->C_Verify(sp->session,
2108 pk11_return_session(sp, OP_DSA);
2360 check_new_dsa_key_pub(PK11_SESSION *sp, DSA *dsa)
2368 if ((sp->opdata_dsa_pub != dsa) ||
2369 (BN_cmp(sp->opdata_dsa_pub_num, dsa->pub_key) != 0)) {
2372 * failure the sp structure will have both key pointer
2376 (void) pk11_destroy_dsa_object_pub(sp, CK_TRUE);
2387 check_new_dsa_key_priv(PK11_SESSION *sp, DSA *dsa)
2395 if ((sp->opdata_dsa_priv != dsa) ||
2396 (BN_cmp(sp->opdata_dsa_priv_num, dsa->priv_key) != 0)) {
2399 * failure the sp structure will have both key pointer
2403 (void) pk11_destroy_dsa_object_priv(sp, CK_TRUE);
2442 PK11_SESSION *sp = NULL;
2513 if ((sp = pk11_get_session(OP_DH)) == NULL) {
2517 rv = pFuncList->C_GenerateKeyPair(sp->session,
2542 rv = pFuncList->C_GetAttributeValue(sp->session, h_pub_key,
2544 rv1 = pFuncList->C_GetAttributeValue(sp->session, h_priv_key,
2564 rv = pFuncList->C_GetAttributeValue(sp->session, h_pub_key,
2592 rv = pFuncList->C_GetAttributeValue(sp->session, h_priv_key,
2621 rv = pFuncList->C_DestroyObject(sp->session, h_pub_key);
2629 rv = pFuncList->C_DestroyObject(sp->session, h_priv_key);
2643 pk11_return_session(sp, OP_DH);
2670 PK11_SESSION *sp = NULL;
2679 if ((sp = pk11_get_session(OP_DH)) == NULL) {
2691 (void) check_new_dh_key(sp, dh);
2693 h_key = sp->opdata_dh_key;
2695 h_key = sp->opdata_dh_key =
2696 pk11_get_dh_key((DH*) dh, &sp->opdata_dh,
2697 &sp->opdata_dh_priv_num, sp->session);
2704 rv = pFuncList->C_DeriveKey(sp->session,
2715 rv = pFuncList->C_GetAttributeValue(sp->session, h_derived_key,
2734 rv = pFuncList->C_GetAttributeValue(sp->session, h_derived_key,
2770 rv = pFuncList->C_DestroyObject(sp->session, h_derived_key);
2786 pk11_return_session(sp, OP_DH);
2923 * Note: we rely on pk11_destroy_dh_key_objects() to set sp->opdata_dh
2927 check_new_dh_key(PK11_SESSION *sp, DH *dh)
2935 if ((sp->opdata_dh != dh) ||
2936 (BN_cmp(sp->opdata_dh_priv_num, dh->priv_key) != 0)) {
2939 * failure the sp structure will have both key pointer
2943 (void) pk11_destroy_dh_object(sp, CK_TRUE);