* AES-CFB8 buffer encryption/decryption */
| 936 | * AES-CFB8 buffer encryption/decryption |
| 937 | */ |
| 938 | int mbedtls_aes_crypt_cfb8(mbedtls_aes_context *ctx, int mode, size_t length, |
| 939 | unsigned char iv[16], const unsigned char *input, |
| 940 | unsigned char *output) { |
| 941 | unsigned char c; |
| 942 | unsigned char ov[17]; |
| 943 | |
| 944 | while (length--) { |
| 945 | memcpy(ov, iv, 16); |
| 946 | mbedtls_aes_crypt_ecb(ctx, MBEDTLS_AES_ENCRYPT, iv, iv); |
| 947 | |
| 948 | if (mode == MBEDTLS_AES_DECRYPT) ov[16] = *input; |
| 949 | |
| 950 | c = *output++ = (unsigned char)(iv[0] ^ *input++); |
| 951 | |
| 952 | if (mode == MBEDTLS_AES_ENCRYPT) ov[16] = c; |
| 953 | |
| 954 | memcpy(iv, ov + 1, 16); |
| 955 | } |
| 956 | |
| 957 | return (0); |
| 958 | } |
| 959 | #endif /*MBEDTLS_CIPHER_MODE_CFB */ |
| 960 | |
| 961 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
nothing calls this directly
no test coverage detected