예제 #1
0
        public OAuthHelper(ICryptoStrategy cryptoStrategy)
        {
            this.ConsumerKey          = Environment.GetEnvironmentVariable("CONSUMER_KEY");
            this.ConsumerSecret       = Environment.GetEnvironmentVariable("CONSUMER_SECRET");
            this.ApiAccessToken       = Environment.GetEnvironmentVariable("TWITTER_ACCESS_TOKEN");
            this.ApiAccessTokenSecret = Environment.GetEnvironmentVariable("TWITTER_ACCESS_TOKEN_SECRET");

            this.cryptoService = cryptoStrategy.CreateCrypto(typeof(HmacSha1Service));
        }
예제 #2
0
 public UserUpdater(IUserRepository userRepository,
                    IMd5CryptoStrategy md5CryptStrategy,
                    ITokenService tokenService,
                    IUnitOfWork unitOfWork)
 {
     _userRepository = userRepository;
     _cryptStrategy  = md5CryptStrategy;
     _tokenService   = tokenService;
     _unitOfWork     = unitOfWork;
 }
예제 #3
0
 public CryptoSignInManager(IUserRepository userRepository, ICryptoStrategy cryptoStrategy)
 {
     if (userRepository == null)
     {
         throw new ArgumentNullException($"{userRepository}");
     }
     if (cryptoStrategy == null)
     {
         throw new ArgumentNullException($"{cryptoStrategy}");
     }
     _userRepository = userRepository;
     _cryptoStrategy = cryptoStrategy;
 }
예제 #4
0
 /// <summary>
 /// Decrypts the given ciphertext using the secret.
 /// </summary>
 /// <param name="cryptoStrategy">The cryptographic strategy to use.</param>
 /// <param name="encryptedData">The data to decrypt.</param>
 /// <param name="optionalAssociatedData">Unencrypted data that can optionally be checked for tampering when using authenticated ciphers.</param>
 /// <returns>The decrypted data.</returns>
 internal Span <byte> Decrypt(ICryptoStrategy cryptoStrategy, EncryptedPacket encryptedData, ReadOnlySpan <byte> optionalAssociatedData = default)
 => cryptoStrategy.Decrypt(encryptedData, this.Key, optionalAssociatedData);
예제 #5
0
 /// <summary>
 /// Encrypts the given data using the secret.
 /// </summary>
 /// <param name="cryptoStrategy">The cryptographic strategy to use.</param>
 /// <param name="plainText">The data to encrypt.</param>
 /// <param name="optionalAssociatedData">Unencrypted data that can optionally be checked for tampering when using authenticated ciphers.</param>
 /// <returns>The encrypted data.</returns>
 internal EncryptedPacket Encrypt(ICryptoStrategy cryptoStrategy, ReadOnlySpan <byte> plainText, ReadOnlySpan <byte> optionalAssociatedData = default)
 => cryptoStrategy.Encrypt(plainText, this.Key, optionalAssociatedData);
예제 #6
0
 /// <summary>
 /// Encrypts the given <see cref="Secret"/>.
 /// </summary>
 /// <param name="cryptoStrategy">The cryptographic strategy to use.</param>
 /// <param name="otherSecret">The <see cref="Secret"/> to encrypt.</param>
 /// <param name="optionalAssociatedData">Unencrypted data that can optionally be checked for tampering when using authenticated ciphers.</param>
 /// <returns>The encrypted <see cref="Secret"/>.</returns>
 internal EncryptedPacket EncryptSecret(ICryptoStrategy cryptoStrategy, Secret otherSecret, ReadOnlySpan <byte> optionalAssociatedData = default)
 => this.Encrypt(cryptoStrategy, otherSecret.Key, optionalAssociatedData);