public byte[] GetPayload(byte[] secureBuffer, int startIndex = 0) { using (var reader = new SecureBufferReader(secureBuffer, startIndex)) { byte[] iv = reader.ReadIv(); byte[] encryptedPayload = reader.ReadPayload(); return(DecryptPayload(encryptedPayload, iv)); } }
public bool IsSecureDataValid(byte[] secureBuffer, int startIndex = 0) { using (var reader = new SecureBufferReader(secureBuffer, startIndex)) { ushort spi = reader.ReadSpi(); byte[] authData = reader.ReadAuthenticatedData(); byte[] storedIcv = reader.ReadStoredIcv(); return(IsSpiValid(spi) && IsIcvValid(authData, storedIcv)); } }