MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ossl_process

Function ossl_process

freebsd/crypto/openssl/ossl.c:199–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197}
198
199static int
200ossl_process(device_t dev, struct cryptop *crp, int hint)
201{
202 struct ossl_hash_context ctx;
203 char digest[HASH_MAX_LEN];
204 const struct crypto_session_params *csp;
205 struct ossl_session *s;
206 struct auth_hash *axf;
207 int error;
208 bool fpu_entered;
209
210 s = crypto_get_driver_session(crp->crp_session);
211 csp = crypto_get_params(crp->crp_session);
212 axf = s->hash.axf;
213
214 if (is_fpu_kern_thread(0)) {
215 fpu_entered = false;
216 } else {
217 fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX);
218 fpu_entered = true;
219 }
220
221 if (crp->crp_auth_key != NULL)
222 ossl_setkey_hmac(s, crp->crp_auth_key, csp->csp_auth_klen);
223
224 ctx = s->hash.ictx;
225
226 if (crp->crp_aad != NULL)
227 error = axf->Update(&ctx, crp->crp_aad, crp->crp_aad_length);
228 else
229 error = crypto_apply(crp, crp->crp_aad_start,
230 crp->crp_aad_length, axf->Update, &ctx);
231 if (error)
232 goto out;
233
234 error = crypto_apply(crp, crp->crp_payload_start,
235 crp->crp_payload_length, axf->Update, &ctx);
236 if (error)
237 goto out;
238
239 axf->Final(digest, &ctx);
240
241 if (csp->csp_auth_klen != 0) {
242 ctx = s->hash.octx;
243 axf->Update(&ctx, digest, axf->hashsize);
244 axf->Final(digest, &ctx);
245 }
246
247 if (crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) {
248 char digest2[HASH_MAX_LEN];
249
250 crypto_copydata(crp, crp->crp_digest_start, s->hash.mlen,
251 digest2);
252 if (timingsafe_bcmp(digest, digest2, s->hash.mlen) != 0)
253 error = EBADMSG;
254 explicit_bzero(digest2, sizeof(digest2));
255 } else {
256 crypto_copyback(crp, crp->crp_digest_start, s->hash.mlen,

Callers

nothing calls this directly

Calls 12

crypto_get_paramsFunction · 0.85
ossl_setkey_hmacFunction · 0.85
crypto_applyFunction · 0.85
crypto_copydataFunction · 0.85
timingsafe_bcmpFunction · 0.85
explicit_bzeroFunction · 0.85
crypto_copybackFunction · 0.85
crypto_doneFunction · 0.85
is_fpu_kern_threadFunction · 0.50
fpu_kern_enterFunction · 0.50
fpu_kern_leaveFunction · 0.50

Tested by

no test coverage detected