IMacFactory <A> IMacFactoryService.CreateMacFactory <A>(A algorithmDetails) { HmacEngineProvider macProvider = (HmacEngineProvider)hmacProviders[algorithmDetails.Algorithm]; int defaultMacSize = macProvider.MacSize; if (key != null) { macProvider = new KeyedHmacEngineProvider(key, macProvider); } if (algorithmDetails.MacSizeInBits != defaultMacSize * 8) { macProvider = new TruncatedHmacEngineProvider(macProvider, algorithmDetails.MacSizeInBits); } return((IMacFactory <A>) new MacFactory <AuthenticationParameters>(algorithmDetails as AuthenticationParameters, macProvider, algorithmDetails.MacSizeInBits / 8)); }
internal TruncatedHmacEngineProvider(HmacEngineProvider provider, int macSizeInBits) : base(macSizeInBits) { this.provider = provider; this.macSizeInBits = macSizeInBits; }
internal KeyedHmacEngineProvider(ISymmetricKey key, HmacEngineProvider provider) : base(provider.MacSize * 8) { this.key = key; this.provider = provider; }