| 229 | } |
| 230 | |
| 231 | int decrypt_siv(const unsigned char *ciphertext, int ciphertext_len, unsigned char *aad, |
| 232 | int aad_len, const unsigned char *siv, const unsigned char *iv, |
| 233 | unsigned char *plaintext, const SivContext *context) |
| 234 | { |
| 235 | |
| 236 | if (aad_len != 24) |
| 237 | return -1; |
| 238 | |
| 239 | unsigned char header_data[24+16]; |
| 240 | |
| 241 | memcpy(header_data, aad, aad_len); |
| 242 | |
| 243 | memcpy(header_data + aad_len, iv, 16); |
| 244 | |
| 245 | size_t header_sizes[2] = { 24, 16 }; |
| 246 | |
| 247 | memcpy(plaintext, ciphertext, ciphertext_len); |
| 248 | |
| 249 | if (!aes256_decrypt_siv(context, header_data, header_sizes, 2, plaintext, ciphertext_len, siv)) |
| 250 | return -1; |
| 251 | |
| 252 | return ciphertext_len; |
| 253 | } |
| 254 | |
| 255 | |
| 256 | bool sha256(const BYTE *data, int datalen, BYTE *sum) |
no test coverage detected