Neither the algorithm class nor the EncCommon class verify that the given symmetric key value k is of the size required by the algorithm. This allows 'failures' in decrypting which are really failures in providing a matching key. This is more of an error mode / message issue than a security issue, since the operation will still fail either way. It would be helpful to compare and raise a ValueError if the len(self.key.k) is different than alg.get_key_length().
|
return alg.decrypt(key=self.key, ciphertext=self.payload, aad=self._enc_structure, nonce=nonce) |
|
return alg.encrypt(key=self.key, data=self.payload, aad=self._enc_structure, nonce=nonce) |
Neither the algorithm class nor the EncCommon class verify that the given symmetric key value
kis of the size required by the algorithm. This allows 'failures' in decrypting which are really failures in providing a matching key. This is more of an error mode / message issue than a security issue, since the operation will still fail either way. It would be helpful to compare and raise a ValueError if thelen(self.key.k)is different thanalg.get_key_length().pycose/pycose/messages/enccommon.py
Line 50 in 1458ddf
pycose/pycose/messages/enccommon.py
Line 69 in 1458ddf