public PskGenerator(PskAuthenticationOptions options)
 {
     _rijndaelIv  = options.RijndaelIV;
     _rijndaelKey = options.RijndaelKey;
     _salt        = options.Salt;
     _secret      = options.Secret;
     _ttl         = options.Ttl;
 }
        public static HttpClient AddPskAuthentication(this HttpClient client, PskAuthenticationOptions options)
        {
            var hash = new PskGenerator(options).Generate();

            client.DefaultRequestHeaders.Add("X-PSK-Authorization", hash);

            return(client);
        }
 public PskGeneratorTests()
 {
     _options = new PskAuthenticationOptions
     {
         RijndaelIV  = "fWN4n4pXsrXSJCdN9HfjiA==",
         RijndaelKey = "J/IsWTGD5Sx2B124mtDg0Pg8AGslPADgGgiOj0kfxh0=",
         Salt        = "fenga1N3BYtRzwV9",
         Secret      = "Banana"
     };
 }
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            var ttl     = 315360000; // 10 years in seconds
            var options = new PskAuthenticationOptions
            {
                RijndaelIV  = _configuration.GetValue <string>("Security:RijndaelIV"),
                RijndaelKey = _configuration.GetValue <string>("Security:RijndaelKey"),
                Salt        = _configuration.GetValue <string>("Security:Salt"),
                Secret      = _configuration.GetValue <string>("Security:Secret"),
                Ttl         = 315360000
            };
            var generator = new PskGenerator(options);
            var psk       = generator.Generate();

            Log.Information("PSK:");
            Log.Information(psk);

            Log.Information("Done!!!");
        }
 public PskAuthenticationFilter(PskAuthenticationOptions options)
 {
     _options = options ?? throw new ArgumentNullException(nameof(options), ""); //TODO: Write error message
 }
 public PskAuthenticationAttribute(PskAuthenticationOptions options)
     : base(typeof(PskAuthenticationFilter))
 {
     Arguments = new object[] { options };
 }