Petri Hintukainen pushed to branch master at VideoLAN / libaacs
Commits: fc36a3c0 by Petri Hintukainen at 2021-04-24T17:29:18+03:00 Use existing helper - - - - - 7cee1c2a by Petri Hintukainen at 2021-04-24T22:36:44+03:00 Remove double logging - - - - - 2 changed files: - src/libaacs/crypto.c - src/util/strutl.c Changes: ===================================== src/libaacs/crypto.c ===================================== @@ -149,7 +149,7 @@ void crypto_aes128e(const uint8_t *key, const uint8_t *data, uint8_t *dst) gcry_cipher_open(&gcry_h, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0); gcry_cipher_setkey(gcry_h, key, 16); - gcry_cipher_encrypt(gcry_h, dst, 16, data, 16); + gcry_cipher_encrypt(gcry_h, dst, 16, data, data ? 16 : 0); gcry_cipher_close(gcry_h); } @@ -196,12 +196,8 @@ static void _shl_128(unsigned char *dst, const unsigned char *src) static void _cmac_key(const unsigned char *aes_key, unsigned char *k1, unsigned char *k2) { uint8_t key[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - gcry_cipher_hd_t gcry_h; - gcry_cipher_open(&gcry_h, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0); - gcry_cipher_setkey(gcry_h, aes_key, 16); - gcry_cipher_encrypt (gcry_h, key, 16, NULL, 0); - gcry_cipher_close(gcry_h); + crypto_aes128e(aes_key, NULL, key); _shl_128(k1, key); if (key[0] & 0x80) { @@ -216,26 +212,21 @@ static void _cmac_key(const unsigned char *aes_key, unsigned char *k1, unsigned void crypto_aes_cmac_16(const unsigned char *data, const unsigned char *aes_key, unsigned char *cmac) { - gcry_cipher_hd_t gcry_h; uint8_t k1[16], k2[16]; unsigned ii; /* - * Somplified version of AES CMAC. Spports only 16-byte input data. + * Simplified version of AES CMAC. Spports only 16-byte input data. */ /* generate CMAC keys */ _cmac_key(aes_key, k1, k2); - memcpy(cmac, data, 16); for (ii = 0; ii < 16; ii++) { cmac[ii] ^= k1[ii]; } - - gcry_cipher_open(&gcry_h, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_ECB, 0); - gcry_cipher_setkey(gcry_h, aes_key, 16); - gcry_cipher_encrypt (gcry_h, cmac, 16, 0, 16); - gcry_cipher_close(gcry_h); + + crypto_aes128e(aes_key, NULL, cmac); } /* ===================================== src/util/strutl.c ===================================== @@ -25,7 +25,6 @@ #include "strutl.h" #include "macro.h" -#include "logging.h" #include <stdio.h> #include <stdarg.h> @@ -111,7 +110,6 @@ static int _hexstring_to_unsigned_char(uint8_t *value, char c) break; default: - BD_DEBUG(DBG_AACS, "Invalid hex value '%c'", c); return 0; } @@ -214,7 +212,6 @@ static int _str_is_hex_string(const char *str, int len) /* check end */ if (isxdigit(str[ii])) { - //BD_DEBUG(DBG_AACS, "Invalid hex string (too long): %s", str); return 0; } View it on GitLab: https://code.videolan.org/videolan/libaacs/-/compare/d6baeea38cacb385ca525da53d8a30dde0eafefd...7cee1c2ac1b0326f4bab3d756b53c5a0ab900002 -- View it on GitLab: https://code.videolan.org/videolan/libaacs/-/compare/d6baeea38cacb385ca525da53d8a30dde0eafefd...7cee1c2ac1b0326f4bab3d756b53c5a0ab900002 You're receiving this email because of your account on code.videolan.org.
_______________________________________________ libaacs-devel mailing list libaacs-devel@videolan.org https://mailman.videolan.org/listinfo/libaacs-devel