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 Add a Jenkinsfile for PR job testing 2018-10-19 16:41:54 +01:00
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 Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
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 Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
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 Revert "Remove tests that depend on TLS or X.509" 2020-03-19 14:17:54 +01:00
make-in-docker.sh Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
Makefile Error out if enumerating the generated data files fails 2021-07-13 18:36:05 +02:00
ssl-opt-in-docker.sh Update copyright notices to use Linux Foundation guidance 2020-08-19 10:35:41 +02:00
ssl-opt.sh Add openssl/gnutls tls1.3 feature tests. 2021-08-11 18:09:49 +08:00