Lines Matching refs:kop
104 static void zapparams(struct crypt_kop *kop);
105 static int cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r,
1062 static void zapparams(struct crypt_kop *kop)
1066 for (i = 0; i < kop->crk_iparams + kop->crk_oparams; i++) {
1067 if (kop->crk_param[i].crp_p)
1068 free(kop->crk_param[i].crp_p);
1069 kop->crk_param[i].crp_p = NULL;
1070 kop->crk_param[i].crp_nbits = 0;
1075 cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen,
1084 kop->crk_param[kop->crk_iparams].crp_p = calloc(rlen, sizeof(char));
1085 kop->crk_param[kop->crk_iparams].crp_nbits = rlen * 8;
1086 kop->crk_oparams++;
1089 kop->crk_param[kop->crk_iparams + 1].crp_p =
1091 kop->crk_param[kop->crk_iparams + 1].crp_nbits = slen * 8;
1092 kop->crk_oparams++;
1095 if (ioctl(fd, CIOCKEY, kop) == 0) {
1097 crparam2bn(&kop->crk_param[kop->crk_iparams], r);
1099 crparam2bn(&kop->crk_param[kop->crk_iparams + 1], s);
1110 struct crypt_kop kop;
1122 memset(&kop, 0, sizeof kop);
1123 kop.crk_op = CRK_MOD_EXP;
1126 if (bn2crparam(a, &kop.crk_param[0]))
1128 if (bn2crparam(p, &kop.crk_param[1]))
1130 if (bn2crparam(m, &kop.crk_param[2]))
1132 kop.crk_iparams = 3;
1134 if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL)) {
1139 } else if (ECANCELED == kop.crk_status) {
1147 zapparams(&kop);
1165 struct crypt_kop kop;
1173 memset(&kop, 0, sizeof kop);
1174 kop.crk_op = CRK_MOD_EXP_CRT;
1176 if (bn2crparam(rsa->p, &kop.crk_param[0]))
1178 if (bn2crparam(rsa->q, &kop.crk_param[1]))
1180 if (bn2crparam(I, &kop.crk_param[2]))
1182 if (bn2crparam(rsa->dmp1, &kop.crk_param[3]))
1184 if (bn2crparam(rsa->dmq1, &kop.crk_param[4]))
1186 if (bn2crparam(rsa->iqmp, &kop.crk_param[5]))
1188 kop.crk_iparams = 6;
1190 if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL)) {
1195 } else if (ECANCELED == kop.crk_status) {
1203 zapparams(&kop);
1265 struct crypt_kop kop;
1276 memset(&kop, 0, sizeof kop);
1277 kop.crk_op = CRK_DSA_SIGN;
1280 kop.crk_param[0].crp_p = (caddr_t) dgst;
1281 kop.crk_param[0].crp_nbits = dlen * 8;
1282 if (bn2crparam(dsa->p, &kop.crk_param[1]))
1284 if (bn2crparam(dsa->q, &kop.crk_param[2]))
1286 if (bn2crparam(dsa->g, &kop.crk_param[3]))
1288 if (bn2crparam(dsa->priv_key, &kop.crk_param[4]))
1290 kop.crk_iparams = 5;
1292 if (cryptodev_asym(&kop, BN_num_bytes(dsa->q), r,
1307 kop.crk_param[0].crp_p = NULL;
1308 zapparams(&kop);
1316 struct crypt_kop kop;
1319 memset(&kop, 0, sizeof kop);
1320 kop.crk_op = CRK_DSA_VERIFY;
1323 kop.crk_param[0].crp_p = (caddr_t) dgst;
1324 kop.crk_param[0].crp_nbits = dlen * 8;
1325 if (bn2crparam(dsa->p, &kop.crk_param[1]))
1327 if (bn2crparam(dsa->q, &kop.crk_param[2]))
1329 if (bn2crparam(dsa->g, &kop.crk_param[3]))
1331 if (bn2crparam(dsa->pub_key, &kop.crk_param[4]))
1333 if (bn2crparam(sig->r, &kop.crk_param[5]))
1335 if (bn2crparam(sig->s, &kop.crk_param[6]))
1337 kop.crk_iparams = 7;
1339 if (cryptodev_asym(&kop, 0, NULL, 0, NULL) == 0) {
1343 if (0 != kop.crk_status)
1351 kop.crk_param[0].crp_p = NULL;
1352 zapparams(&kop);
1380 struct crypt_kop kop;
1392 memset(&kop, 0, sizeof kop);
1393 kop.crk_op = CRK_DH_COMPUTE_KEY;
1396 if (bn2crparam(dh->priv_key, &kop.crk_param[0]))
1398 if (bn2crparam(pub_key, &kop.crk_param[1]))
1400 if (bn2crparam(dh->p, &kop.crk_param[2]))
1402 kop.crk_iparams = 3;
1404 kop.crk_param[3].crp_p = (caddr_t) key;
1405 kop.crk_param[3].crp_nbits = keylen * 8;
1406 kop.crk_oparams = 1;
1408 if (ioctl(fd, CIOCKEY, &kop) == -1) {
1414 kop.crk_param[3].crp_p = NULL;
1415 zapparams(&kop);