Lines Matching defs:plaintext
405 aes_encrypt(crypto_ctx_t *ctx, crypto_data_t *plaintext,
417 * For block ciphers, plaintext must be a multiple of AES block size.
421 == 0) && (plaintext->cd_length & (AES_BLOCK_LEN - 1)) != 0)
424 AES_ARG_INPLACE(plaintext, ciphertext);
432 length_needed = plaintext->cd_length + aes_ctx->ac_mac_len;
435 length_needed = plaintext->cd_length + aes_ctx->ac_tag_len;
438 if (plaintext->cd_length != 0)
444 length_needed = plaintext->cd_length;
458 ret = aes_encrypt_update(ctx, plaintext, ciphertext, req);
483 if (plaintext != ciphertext) {
505 if (plaintext != ciphertext) {
521 crypto_data_t *plaintext, crypto_req_handle_t req)
533 * For block ciphers, plaintext must be a multiple of AES block size.
541 AES_ARG_INPLACE(ciphertext, plaintext);
545 * Do not destroy context when plaintext buffer is too small.
547 * CCM: plaintext is MAC len smaller than cipher text
548 * GCM: plaintext is TAG len smaller than cipher text
549 * GMAC: plaintext length must be zero
559 if (plaintext->cd_length != 0)
568 if (plaintext->cd_length < length_needed) {
569 plaintext->cd_length = length_needed;
573 saved_offset = plaintext->cd_offset;
574 saved_length = plaintext->cd_length;
579 ret = aes_decrypt_update(ctx, ciphertext, plaintext, req);
589 plaintext->cd_offset = plaintext->cd_length;
590 plaintext->cd_length = saved_length - plaintext->cd_length;
592 ret = ccm_decrypt_final((ccm_ctx_t *)aes_ctx, plaintext,
596 if (plaintext != ciphertext) {
597 plaintext->cd_length =
598 plaintext->cd_offset - saved_offset;
601 plaintext->cd_length = saved_length;
604 plaintext->cd_offset = saved_offset;
607 plaintext->cd_offset = plaintext->cd_length;
608 plaintext->cd_length = saved_length - plaintext->cd_length;
610 ret = gcm_decrypt_final((gcm_ctx_t *)aes_ctx, plaintext,
613 if (plaintext != ciphertext) {
614 plaintext->cd_length =
615 plaintext->cd_offset - saved_offset;
618 plaintext->cd_length = saved_length;
621 plaintext->cd_offset = saved_offset;
635 aes_encrypt_update(crypto_ctx_t *ctx, crypto_data_t *plaintext,
646 AES_ARG_INPLACE(plaintext, ciphertext);
650 out_len += plaintext->cd_length;
665 switch (plaintext->cd_format) {
668 plaintext, ciphertext, aes_encrypt_contiguous_blocks,
673 plaintext, ciphertext, aes_encrypt_contiguous_blocks,
678 plaintext, ciphertext, aes_encrypt_contiguous_blocks,
697 if (plaintext != ciphertext)
711 crypto_data_t *plaintext, crypto_req_handle_t req)
721 AES_ARG_INPLACE(ciphertext, plaintext);
724 * Compute number of bytes that will hold the plaintext.
726 * mechanisms never return plaintext for update operations.
734 if (plaintext->cd_length < out_len) {
735 plaintext->cd_length = out_len;
740 saved_offset = plaintext->cd_offset;
741 saved_length = plaintext->cd_length;
752 ciphertext, plaintext, aes_decrypt_contiguous_blocks,
757 ciphertext, plaintext, aes_decrypt_contiguous_blocks,
762 ciphertext, plaintext, aes_decrypt_contiguous_blocks,
776 ret = ctr_mode_final((ctr_ctx_t *)aes_ctx, plaintext,
783 if (ciphertext != plaintext)
784 plaintext->cd_length =
785 plaintext->cd_offset - saved_offset;
787 plaintext->cd_length = saved_length;
789 plaintext->cd_offset = saved_offset;
838 * There must be no unprocessed plaintext.
892 * This is where all the plaintext is returned, make sure
893 * the plaintext buffer is big enough
920 * This is where all the plaintext is returned, make sure
921 * the plaintext buffer is big enough
961 crypto_key_t *key, crypto_data_t *plaintext, crypto_data_t *ciphertext,
970 AES_ARG_INPLACE(plaintext, ciphertext);
973 * CTR, CCM, GCM, and GMAC modes do not require that plaintext
983 if ((plaintext->cd_length & (AES_BLOCK_LEN - 1)) != 0)
999 length_needed = plaintext->cd_length + aes_ctx.ac_mac_len;
1002 if (plaintext->cd_length != 0)
1006 length_needed = plaintext->cd_length + aes_ctx.ac_tag_len;
1009 length_needed = plaintext->cd_length;
1025 switch (plaintext->cd_format) {
1027 ret = crypto_update_iov(&aes_ctx, plaintext, ciphertext,
1031 ret = crypto_update_uio(&aes_ctx, plaintext, ciphertext,
1035 ret = crypto_update_mp(&aes_ctx, plaintext, ciphertext,
1069 if (plaintext != ciphertext) {
1091 crypto_key_t *key, crypto_data_t *ciphertext, crypto_data_t *plaintext,
1100 AES_ARG_INPLACE(ciphertext, plaintext);
1135 if (plaintext->cd_length != 0)
1144 if (plaintext->cd_length < length_needed) {
1145 plaintext->cd_length = length_needed;
1150 saved_offset = plaintext->cd_offset;
1151 saved_length = plaintext->cd_length;
1162 ret = crypto_update_iov(&aes_ctx, ciphertext, plaintext,
1166 ret = crypto_update_uio(&aes_ctx, ciphertext, plaintext,
1170 ret = crypto_update_mp(&aes_ctx, ciphertext, plaintext,
1184 plaintext, AES_BLOCK_LEN, aes_encrypt_block,
1188 (ciphertext != plaintext)) {
1189 plaintext->cd_length =
1190 plaintext->cd_offset - saved_offset;
1192 plaintext->cd_length = saved_length;
1197 plaintext, AES_BLOCK_LEN, aes_encrypt_block,
1201 (ciphertext != plaintext)) {
1202 plaintext->cd_length =
1203 plaintext->cd_offset - saved_offset;
1205 plaintext->cd_length = saved_length;
1209 if (ciphertext != plaintext)
1210 plaintext->cd_length =
1211 plaintext->cd_offset - saved_offset;
1215 plaintext, aes_encrypt_block);
1221 if (ciphertext != plaintext)
1222 plaintext->cd_length =
1223 plaintext->cd_offset - saved_offset;
1226 plaintext->cd_length = saved_length;
1228 plaintext->cd_offset = saved_offset;