/// <summary> /// Constructs Kas parameter information /// </summary> /// <param name="keyAgreementRole">This party's key agreement role</param> /// <param name="kasMode">The mode of the KAS attempt</param> /// <param name="keyConfirmationRole">This party's key confirmation role</param> /// <param name="keyConfirmationDirection">This party's key confirmation direction</param> /// <param name="kasAssurances">The assurances associated with the KAS</param> /// <param name="thisPartyId">The ID associated with this party</param> protected SchemeParametersBase( TKasAlgoAttributes kasAlgoAttributes, KeyAgreementRole keyAgreementRole, KasMode kasMode, KeyConfirmationRole keyConfirmationRole, KeyConfirmationDirection keyConfirmationDirection, KasAssurance kasAssurances, BitString thisPartyId ) { if (kasMode != KasMode.NoKdfNoKc && BitString.IsZeroLengthOrNull(thisPartyId)) { throw new ArgumentException(nameof(thisPartyId)); } if (kasMode == KasMode.KdfKc) { if (keyConfirmationRole == KeyConfirmationRole.None || keyConfirmationDirection == KeyConfirmationDirection.None) { throw new ArgumentException( $"{nameof(KasMode.KdfKc)} requires a valid (not None) value for both {nameof(keyConfirmationRole)} and {nameof(keyConfirmationDirection)}"); } } KasAlgoAttributes = kasAlgoAttributes; KeyAgreementRole = keyAgreementRole; KasMode = kasMode; KeyConfirmationRole = keyConfirmationRole; KeyConfirmationDirection = keyConfirmationDirection; KasAssurances = kasAssurances; ThisPartyId = thisPartyId; }
public NoKeyConfirmationAesCcm(INoKeyConfirmationMacDataCreator macDataCreator, INoKeyConfirmationParameters noKeyConfirmationParameters, IAeadModeBlockCipher algo) : base(macDataCreator, noKeyConfirmationParameters) { _algo = algo; if (BitString.IsZeroLengthOrNull(noKeyConfirmationParameters.CcmNonce)) { throw new ArgumentException(nameof(noKeyConfirmationParameters.CcmNonce)); } }
protected NoKeyConfirmationBase( INoKeyConfirmationMacDataCreator macDataCreator, INoKeyConfirmationParameters noKeyConfirmationParameters) { _macDataCreator = macDataCreator; NoKeyConfirmationParameters = noKeyConfirmationParameters; if (BitString.IsZeroLengthOrNull(NoKeyConfirmationParameters.DerivedKeyingMaterial)) { throw new ArgumentException(nameof(NoKeyConfirmationParameters.DerivedKeyingMaterial)); } if (BitString.IsZeroLengthOrNull(NoKeyConfirmationParameters.Nonce)) { throw new ArgumentException(nameof(NoKeyConfirmationParameters.Nonce)); } }
/// <summary> /// Constructor used for AES-CCM NoKeyConfirmation /// </summary> /// <param name="keyAgreementMacType">The MAC type used</param> /// <param name="derivedKeyingMaterial">The keying material used as the MAC key</param> /// <param name="macLength">The returned MAC length</param> /// <param name="nonce">The nonce used (concatenated onto "Standard Test Message")</param> /// <param name="ccmNonce">The Nonce used in AES-CCM</param> public NoKeyConfirmationParameters(KeyAgreementMacType keyAgreementMacType, int macLength, BitString derivedKeyingMaterial, BitString nonce, BitString ccmNonce) { if (keyAgreementMacType != KeyAgreementMacType.AesCcm) { throw new ArgumentException(nameof(keyAgreementMacType)); } if (BitString.IsZeroLengthOrNull(ccmNonce)) { throw new ArgumentException(nameof(ccmNonce)); } KeyAgreementMacType = keyAgreementMacType; MacLength = macLength; DerivedKeyingMaterial = derivedKeyingMaterial; Nonce = nonce; CcmNonce = ccmNonce; }
/// <summary> /// AES-CCM constructor /// </summary> /// <param name="thisPartyKeyAgreementRole"></param> /// <param name="thisPartyKeyConfirmationRole"></param> /// <param name="keyConfirmationType"></param> /// <param name="macType"></param> /// <param name="keyLength"></param> /// <param name="macLength"></param> /// <param name="thisPartyIdentifier"></param> /// <param name="otherPartyIdentifier"></param> /// <param name="thisPartyPublicKey"></param> /// <param name="otherPartyPublicKey"></param> /// <param name="derivedKeyingMaterial"></param> /// <param name="ccmNonce"></param> public KeyConfirmationParameters( KeyAgreementRole thisPartyKeyAgreementRole, KeyConfirmationRole thisPartyKeyConfirmationRole, KeyConfirmationDirection keyConfirmationType, KeyAgreementMacType macType, int keyLength, int macLength, BitString thisPartyIdentifier, BitString otherPartyIdentifier, BitString thisPartyPublicKey, BitString otherPartyPublicKey, BitString derivedKeyingMaterial, BitString ccmNonce) { if (macType != KeyAgreementMacType.AesCcm) { throw new ArgumentException(nameof(macType)); } if (BitString.IsZeroLengthOrNull(ccmNonce)) { throw new ArgumentException(nameof(ccmNonce)); } ThisPartyKeyAgreementRole = thisPartyKeyAgreementRole; ThisPartyKeyConfirmationRole = thisPartyKeyConfirmationRole; KeyConfirmationType = keyConfirmationType; MacType = macType; KeyLength = keyLength; MacLength = macLength; ThisPartyIdentifier = thisPartyIdentifier; OtherPartyIdentifier = otherPartyIdentifier; ThisPartyPublicKey = thisPartyPublicKey; OtherPartyPublicKey = otherPartyPublicKey; DerivedKeyingMaterial = derivedKeyingMaterial; KeyConfirmationType = keyConfirmationType; CcmNonce = ccmNonce; }