85
86 int
87 cryptotest_close(crypto_op_t *op)
88 {
89 (void) C_DestroyObject(op->hsession, op->keyt);
90 if (op->hsession != CRYPTO_INVALID_SESSION)
91 (void) cryptotest_close_session(op->hsession);
92 free(op);
93 return (C_Finalize(NULL));
94 }
95
96 int
97 get_mech_info(crypto_op_t *op)
98 {
99 CK_RV rv;
100 rv = pkcs11_str2mech(op->mechname, &op->mech);
101 if (rv != CKR_OK) {
102 cryptotest_error("get_mech_info", rv);
103 (void) fprintf(stderr, "failed to resolve mechanism name %s\n",
104 op->mechname);
105 (void) cryptotest_close(op);
106 return (CTEST_NAME_RESOLVE_FAILED);
107 }
108 return (rv);
109 }
110
111
112 int
113 get_hsession_by_mech(crypto_op_t *op)
114 {
115 CK_RV rv;
116 rv = SUNW_C_GetMechSession(op->mech, &op->hsession);
117 if (rv != CKR_OK) {
118 cryptotest_error("get_hsession_by_mech", rv);
119 (void) fprintf(stderr,
120 "could not find provider for mechanism %lu\n",
121 op->mech);
122 (void) cryptotest_close(op);
123 return (CTEST_MECH_NO_PROVIDER);
124 }
125 return (rv);
126 }
127
128 /*
129 * SIGN_* functions
130 */
131 int
132 sign_init(crypto_op_t *op)
133 {
134 CK_MECHANISM mech;
135 CK_RV rv;
136
137 mech.mechanism = op->mech;
138 mech.pParameter = NULL;
139 mech.ulParameterLen = 0;
140
141 rv = SUNW_C_KeyToObject(op->hsession, op->mech,
142 op->key, op->keylen, &op->keyt);
|
85
86 int
87 cryptotest_close(crypto_op_t *op)
88 {
89 (void) C_DestroyObject(op->hsession, op->keyt);
90 if (op->hsession != CRYPTO_INVALID_SESSION)
91 (void) cryptotest_close_session(op->hsession);
92 free(op);
93 return (C_Finalize(NULL));
94 }
95
96 int
97 get_mech_info(crypto_op_t *op)
98 {
99 CK_RV rv;
100 rv = pkcs11_str2mech(op->mechname, &op->mech);
101 if (rv != CKR_OK) {
102 cryptotest_error("get_mech_info", rv);
103 (void) fprintf(stderr, "failed to resolve mechanism name %s\n",
104 op->mechname);
105 return (CTEST_NAME_RESOLVE_FAILED);
106 }
107 return (rv);
108 }
109
110
111 int
112 get_hsession_by_mech(crypto_op_t *op)
113 {
114 CK_RV rv;
115 rv = SUNW_C_GetMechSession(op->mech, &op->hsession);
116 if (rv != CKR_OK) {
117 cryptotest_error("get_hsession_by_mech", rv);
118 (void) fprintf(stderr,
119 "could not find provider for mechanism %lu\n",
120 op->mech);
121 return (CTEST_MECH_NO_PROVIDER);
122 }
123 return (rv);
124 }
125
126 /*
127 * SIGN_* functions
128 */
129 int
130 sign_init(crypto_op_t *op)
131 {
132 CK_MECHANISM mech;
133 CK_RV rv;
134
135 mech.mechanism = op->mech;
136 mech.pParameter = NULL;
137 mech.ulParameterLen = 0;
138
139 rv = SUNW_C_KeyToObject(op->hsession, op->mech,
140 op->key, op->keylen, &op->keyt);
|