public UserService( ICryptoHash cryptoHash, IJwtService jwtService, IBankAccountService bankAccountService, IUserRepository userRepository, IUnitOfWork unitOfWork, ILogger <IUserService> logger) { this.CryptoHash = cryptoHash; this.JwtService = jwtService; this.BankAccountService = bankAccountService; this.UserRepository = userRepository; this.UnitOfWork = unitOfWork; this.Logger = logger; }
public byte[] Transform(byte[] buffer) { if (buffer == null) { throw new ArgumentNullException("buffer"); } int rsaKeyBitSize = ((RsaKeyParameters)Key).Modulus.BitLength; ICryptoHash paddingHash = New <IAsymmetricFactory>().CreatePaddingHash(rsaKeyBitSize); int requiredBits = (paddingHash.HashSize * 2 + buffer.Length + 1) * 8; if (requiredBits > rsaKeyBitSize) { throw new InvalidOperationException("The RSA Key size is too small to fit the data + 1 + 2 times the padding hash size."); } IAsymmetricBlockCipher cipher = new OaepEncoding(new RsaBlindedEngine(), new BouncyCastleDigest(paddingHash)); cipher.Init(true, new ParametersWithRandom(Key, BouncyCastleRandomGenerator.CreateSecureRandom())); return(TransformInternal(buffer, cipher)); }
public BouncyCastleDigest(ICryptoHash cryptoHash) { _cryptoHash = cryptoHash; }