Lines Matching refs:kop
96 static void zapparams(struct crypt_kop *kop);
97 static int cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r,
680 zapparams(struct crypt_kop *kop)
684 for (i = 0; i <= kop->crk_iparams + kop->crk_oparams; i++) {
685 if (kop->crk_param[i].crp_p)
686 free(kop->crk_param[i].crp_p);
687 kop->crk_param[i].crp_p = NULL;
688 kop->crk_param[i].crp_nbits = 0;
693 cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen, BIGNUM *s)
701 kop->crk_param[kop->crk_iparams].crp_p = calloc(rlen, sizeof(char));
702 kop->crk_param[kop->crk_iparams].crp_nbits = rlen * 8;
703 kop->crk_oparams++;
706 kop->crk_param[kop->crk_iparams+1].crp_p = calloc(slen, sizeof(char));
707 kop->crk_param[kop->crk_iparams+1].crp_nbits = slen * 8;
708 kop->crk_oparams++;
711 if (ioctl(fd, CIOCKEY, kop) == 0) {
713 crparam2bn(&kop->crk_param[kop->crk_iparams], r);
715 crparam2bn(&kop->crk_param[kop->crk_iparams+1], s);
726 struct crypt_kop kop;
737 memset(&kop, 0, sizeof kop);
738 kop.crk_op = CRK_MOD_EXP;
741 if (bn2crparam(a, &kop.crk_param[0]))
743 if (bn2crparam(p, &kop.crk_param[1]))
745 if (bn2crparam(m, &kop.crk_param[2]))
747 kop.crk_iparams = 3;
749 if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL) == -1) {
754 zapparams(&kop);
773 struct crypt_kop kop;
781 memset(&kop, 0, sizeof kop);
782 kop.crk_op = CRK_MOD_EXP_CRT;
784 if (bn2crparam(rsa->p, &kop.crk_param[0]))
786 if (bn2crparam(rsa->q, &kop.crk_param[1]))
788 if (bn2crparam(I, &kop.crk_param[2]))
790 if (bn2crparam(rsa->dmp1, &kop.crk_param[3]))
792 if (bn2crparam(rsa->dmq1, &kop.crk_param[4]))
794 if (bn2crparam(rsa->iqmp, &kop.crk_param[5]))
796 kop.crk_iparams = 6;
798 if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL) == -1) {
803 zapparams(&kop);
865 struct crypt_kop kop;
876 memset(&kop, 0, sizeof kop);
877 kop.crk_op = CRK_DSA_SIGN;
880 kop.crk_param[0].crp_p = (caddr_t)dgst;
881 kop.crk_param[0].crp_nbits = dlen * 8;
882 if (bn2crparam(dsa->p, &kop.crk_param[1]))
884 if (bn2crparam(dsa->q, &kop.crk_param[2]))
886 if (bn2crparam(dsa->g, &kop.crk_param[3]))
888 if (bn2crparam(dsa->priv_key, &kop.crk_param[4]))
890 kop.crk_iparams = 5;
892 if (cryptodev_asym(&kop, BN_num_bytes(dsa->q), r,
904 kop.crk_param[0].crp_p = NULL;
905 zapparams(&kop);
913 struct crypt_kop kop;
916 memset(&kop, 0, sizeof kop);
917 kop.crk_op = CRK_DSA_VERIFY;
920 kop.crk_param[0].crp_p = (caddr_t)dgst;
921 kop.crk_param[0].crp_nbits = dlen * 8;
922 if (bn2crparam(dsa->p, &kop.crk_param[1]))
924 if (bn2crparam(dsa->q, &kop.crk_param[2]))
926 if (bn2crparam(dsa->g, &kop.crk_param[3]))
928 if (bn2crparam(dsa->pub_key, &kop.crk_param[4]))
930 if (bn2crparam(sig->r, &kop.crk_param[5]))
932 if (bn2crparam(sig->s, &kop.crk_param[6]))
934 kop.crk_iparams = 7;
936 if (cryptodev_asym(&kop, 0, NULL, 0, NULL) == 0) {
937 dsaret = kop.crk_status;
944 kop.crk_param[0].crp_p = NULL;
945 zapparams(&kop);
973 struct crypt_kop kop;
985 memset(&kop, 0, sizeof kop);
986 kop.crk_op = CRK_DH_COMPUTE_KEY;
989 if (bn2crparam(dh->priv_key, &kop.crk_param[0]))
991 if (bn2crparam(pub_key, &kop.crk_param[1]))
993 if (bn2crparam(dh->p, &kop.crk_param[2]))
995 kop.crk_iparams = 3;
997 kop.crk_param[3].crp_p = key;
998 kop.crk_param[3].crp_nbits = keylen * 8;
999 kop.crk_oparams = 1;
1001 if (ioctl(fd, CIOCKEY, &kop) == -1) {
1007 kop.crk_param[3].crp_p = NULL;
1008 zapparams(&kop);