public void ShouldReturnCorrectMac(
            int keySize, int tagLength,
            BitString serverId, BitString iutId,
            BitString serverPublicKey, BitString iutPublicKey,
            BitString derivedKeyingMaterial,
            BitString expectedMacData, BitString expectedTag)
        {
            var cmac = _cmacFactory.GetCmacInstance(CmacTypes.AES128); // doesn't matter for scope of testing this, as long as AES

            var p = new KeyConfirmationParameters(
                KeyAgreementRole.InitiatorPartyU,
                KeyConfirmationRole.Provider,
                KeyConfirmationDirection.Bilateral,
                KeyAgreementMacType.CmacAes, // note this doesn't matter for the scope of this test
                keySize,
                tagLength,
                iutId,
                serverId,
                iutPublicKey,
                serverPublicKey,
                derivedKeyingMaterial
                );

            _subject = new KeyConfirmationCmac(new KeyConfirmationMacDataCreator(), p, cmac);

            var result = _subject.ComputeMac();

            Assert.That(result.Success);
            Assert.AreEqual(expectedMacData.ToHex(), result.MacData.ToHex(), nameof(expectedMacData));
            Assert.AreEqual(expectedTag.ToHex(), result.Mac.ToHex(), nameof(expectedTag));
        }
예제 #2
0
        public void ShouldReturnProperCmacInstance(CmacTypes cmacType, Type expectedType)
        {
            var result = _subject.GetCmacInstance(cmacType);

            Assert.IsInstanceOf(expectedType, result);
        }