Lines Matching +full:armv8 +full:- +full:based

1 /*-
2 * Copyright (c) 2005-2008 Pawel Jakub Dawidek <pjd@FreeBSD.org>
8 * Portions of this software were developed by John-Mark Gurney
38 * This is based on the aesni code.
58 #include <crypto/armv8/armv8_crypto.h>
69 MALLOC_DEFINE(M_ARMV8_CRYPTO, "armv8_crypto", "ARMv8 Crypto Data");
76 if (device_find_child(parent, "armv8crypto", -1) == NULL && in armv8_crypto_identify()
77 BUS_ADD_CHILD(parent, 10, "armv8crypto", -1) == 0) in armv8_crypto_identify()
78 panic("ARMv8 crypto: could not attach"); in armv8_crypto_identify()
92 device_set_desc(dev, "AES-CBC,AES-XTS"); in armv8_crypto_probe()
96 device_set_desc(dev, "AES-CBC,AES-XTS,AES-GCM"); in armv8_crypto_probe()
121 sc->has_pmul = true; in armv8_crypto_attach()
123 sc->cid = crypto_get_driverid(dev, sizeof(struct armv8_crypto_session), in armv8_crypto_attach()
125 if (sc->cid < 0) { in armv8_crypto_attach()
140 crypto_unregister_all(sc->cid); in armv8_crypto_detach()
155 if ((csp->csp_flags & ~(SUPPORTED_SES)) != 0) in armv8_crypto_probesession()
158 switch (csp->csp_mode) { in armv8_crypto_probesession()
160 switch (csp->csp_cipher_alg) { in armv8_crypto_probesession()
162 if (!sc->has_pmul) in armv8_crypto_probesession()
164 if (csp->csp_auth_mlen != 0 && in armv8_crypto_probesession()
165 csp->csp_auth_mlen != GMAC_DIGEST_LEN) in armv8_crypto_probesession()
167 switch (csp->csp_cipher_klen * 8) { in armv8_crypto_probesession()
181 switch (csp->csp_cipher_alg) { in armv8_crypto_probesession()
183 if (csp->csp_ivlen != AES_BLOCK_LEN) in armv8_crypto_probesession()
185 switch (csp->csp_cipher_klen * 8) { in armv8_crypto_probesession()
195 if (csp->csp_ivlen != AES_XTS_IV_LEN) in armv8_crypto_probesession()
197 switch (csp->csp_cipher_klen * 8) { in armv8_crypto_probesession()
221 if (csp->csp_cipher_alg == CRYPTO_AES_XTS) in armv8_crypto_cipher_setup()
236 keylen * 8, &ses->enc_schedule); in armv8_crypto_cipher_setup()
238 if ((csp->csp_cipher_alg == CRYPTO_AES_XTS) || in armv8_crypto_cipher_setup()
239 (csp->csp_cipher_alg == CRYPTO_AES_CBC)) in armv8_crypto_cipher_setup()
241 keylen * 8, &ses->dec_schedule); in armv8_crypto_cipher_setup()
243 if (csp->csp_cipher_alg == CRYPTO_AES_XTS) in armv8_crypto_cipher_setup()
244 aes_v8_set_encrypt_key(key + keylen, keylen * 8, &ses->xts_schedule); in armv8_crypto_cipher_setup()
246 if (csp->csp_cipher_alg == CRYPTO_AES_NIST_GCM_16) { in armv8_crypto_cipher_setup()
248 aes_v8_encrypt(H.c, H.c, &ses->enc_schedule); in armv8_crypto_cipher_setup()
251 gcm_init_v8(ses->Htable, H.u); in armv8_crypto_cipher_setup()
267 error = armv8_crypto_cipher_setup(ses, csp, csp->csp_cipher_key, in armv8_crypto_newsession()
268 csp->csp_cipher_klen); in armv8_crypto_newsession()
277 ses = crypto_get_driver_session(crp->crp_session); in armv8_crypto_process()
278 crp->crp_etype = armv8_crypto_cipher_process(ses, crp); in armv8_crypto_process()
293 addr = malloc(crp->crp_payload_length, M_ARMV8_CRYPTO, M_NOWAIT); in armv8_crypto_cipher_alloc()
314 csp = crypto_get_params(crp->crp_session); in armv8_crypto_cipher_process()
315 encflag = CRYPTO_OP_IS_ENCRYPT(crp->crp_op); in armv8_crypto_cipher_process()
320 if (csp->csp_cipher_alg == CRYPTO_AES_NIST_GCM_16) { in armv8_crypto_cipher_process()
321 if (crp->crp_aad != NULL) in armv8_crypto_cipher_process()
322 authbuf = crp->crp_aad; in armv8_crypto_cipher_process()
324 authbuf = armv8_crypto_cipher_alloc(crp, crp->crp_aad_start, in armv8_crypto_cipher_process()
325 crp->crp_aad_length, &authallocated); in armv8_crypto_cipher_process()
329 crypto_cursor_init(&fromc, &crp->crp_buf); in armv8_crypto_cipher_process()
330 crypto_cursor_advance(&fromc, crp->crp_payload_start); in armv8_crypto_cipher_process()
332 crypto_cursor_init(&toc, &crp->crp_obuf); in armv8_crypto_cipher_process()
333 crypto_cursor_advance(&toc, crp->crp_payload_output_start); in armv8_crypto_cipher_process()
338 if (crp->crp_cipher_key != NULL) { in armv8_crypto_cipher_process()
339 armv8_crypto_cipher_setup(ses, csp, crp->crp_cipher_key, in armv8_crypto_cipher_process()
340 csp->csp_cipher_klen); in armv8_crypto_cipher_process()
348 switch (csp->csp_cipher_alg) { in armv8_crypto_cipher_process()
350 if ((crp->crp_payload_length % AES_BLOCK_LEN) != 0) { in armv8_crypto_cipher_process()
355 armv8_aes_encrypt_cbc(&ses->enc_schedule, in armv8_crypto_cipher_process()
356 crp->crp_payload_length, &fromc, &toc, iv); in armv8_crypto_cipher_process()
358 armv8_aes_decrypt_cbc(&ses->dec_schedule, in armv8_crypto_cipher_process()
359 crp->crp_payload_length, &fromc, &toc, iv); in armv8_crypto_cipher_process()
363 armv8_aes_encrypt_xts(&ses->enc_schedule, in armv8_crypto_cipher_process()
364 &ses->xts_schedule.aes_key, crp->crp_payload_length, in armv8_crypto_cipher_process()
367 armv8_aes_decrypt_xts(&ses->dec_schedule, in armv8_crypto_cipher_process()
368 &ses->xts_schedule.aes_key, crp->crp_payload_length, in armv8_crypto_cipher_process()
374 armv8_aes_encrypt_gcm(&ses->enc_schedule, in armv8_crypto_cipher_process()
375 crp->crp_payload_length, &fromc, &toc, in armv8_crypto_cipher_process()
376 crp->crp_aad_length, authbuf, tag, iv, ses->Htable); in armv8_crypto_cipher_process()
377 crypto_copyback(crp, crp->crp_digest_start, sizeof(tag), in armv8_crypto_cipher_process()
380 crypto_copydata(crp, crp->crp_digest_start, sizeof(tag), in armv8_crypto_cipher_process()
382 error = armv8_aes_decrypt_gcm(&ses->enc_schedule, in armv8_crypto_cipher_process()
383 crp->crp_payload_length, &fromc, &toc, in armv8_crypto_cipher_process()
384 crp->crp_aad_length, authbuf, tag, iv, ses->Htable); in armv8_crypto_cipher_process()