mbedtls/tests
Mateusz Starzyk efec38bb29 Extend CCM corner cases tests.
Add tests covering skipped update() or update_ad()
for empty plaintext/ciphertext and empty auth data.

Test vector for P=0, A=0 generated using python's
cryptography.hazmat library.

Python script used for test vector generation:
```
import os
from cryptography.hazmat.primitives.ciphers.aead import AESCCM

def encrypt(key, iv, plaintext, associated_data):

    key = bytes.fromhex(key)
    iv = bytes.fromhex(iv)
    plaintext = bytes.fromhex(plaintext)
    associated_data = bytes.fromhex(associated_data)

    aesccm = AESCCM(key)
    ct = aesccm.encrypt(iv, plaintext, associated_data)
    return ct.hex()

def decrypt(key, associated_data, iv, ciphertext):

    key = bytes.fromhex(key)
    associated_data = bytes.fromhex(associated_data)
    iv = bytes.fromhex(iv)
    ciphertext = bytes.fromhex(ciphertext)

    aesccm = AESCCM(key)
    pt = aesccm.decrypt(iv, ciphertext, associated_data)
    return pt.hex()

key = "54caf96ef6d448734700aadab50faf7a"
plaintext = ""
iv = "a3803e752ae849c910d8da36af"
aad = ""

encrypted = encrypt(key, iv, plaintext, aad)

print(f"key: {key}")
print(f"iv: {iv}")
print(f"encrypted: {encrypted}")

print("--------------------------------------")

decrypted = decrypt(
    key,
    aad,
    iv,
    encrypted
)

print(f"decrypted: {decrypted}")
```

Results:
```
key: 54caf96ef6d448734700aadab50faf7a
iv: a3803e752ae849c910d8da36af
encrypted: eba8347baa6d61f87b67c2dd7c6d2053
--------------------------------------
decrypted:
```

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
2021-09-06 12:09:34 +02:00
..
.jenkins
configs Rename config.h to mbedtls_config.h 2021-06-28 09:28:33 +01:00
data_files Removal of RC4 certs and fixes to docs and tests 2021-06-21 13:27:29 +02:00
docker/bionic
git-scripts Remove Git pre-commit hook 2021-05-20 10:37:22 +02:00
include Adding new macro for tests failing 2021-07-09 14:27:04 +02:00
scripts Merge pull request #3572 from mpg/add-arm-linux-build 2021-08-12 13:16:02 +02:00
src Adding new macro for tests failing 2021-07-09 14:27:04 +02:00
suites Extend CCM corner cases tests. 2021-09-06 12:09:34 +02:00
.gitignore Ignore generated source files that are no longer checked in 2021-05-20 10:37:22 +02:00
CMakeLists.txt Remove MD2, MD4, RC4, Blowfish and XTEA 2021-06-16 10:34:25 +02:00
compat-in-docker.sh
compat.sh Rename config.h to mbedtls_config.h 2021-06-28 09:28:33 +01:00
context-info.sh Modifies tests in context-info.sh 2021-06-16 16:19:53 +01:00
Descriptions.txt
make-in-docker.sh
Makefile Error out if enumerating the generated data files fails 2021-07-13 18:36:05 +02:00
ssl-opt-in-docker.sh
ssl-opt.sh Add openssl/gnutls tls1.3 feature tests. 2021-08-11 18:09:49 +08:00