コード例 #1
0
        public void ShouldHandleSha512()
        {
            var generator = new PskGenerator(_options);
            var hash      = generator.Generate();

            hash.Should().NotBeEmpty();
        }
コード例 #2
0
        public void ShouldHandleSha384()
        {
            var generator = new PskGenerator(_options).UseAlgorithm(SHA384.Create());
            var hash      = generator.Generate();

            hash.Should().NotBeEmpty();
        }
コード例 #3
0
        public static HttpClient AddPskAuthentication(this HttpClient client, string iv, string key, string salt, string secret, int ttl = 900)
        {
            var hash = new PskGenerator(iv, key).Generate(salt, secret, ttl);

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

            return(client);
        }
コード例 #4
0
        public static HttpClient AddPskAuthentication(this HttpClient client, PskAuthenticationOptions options)
        {
            var hash = new PskGenerator(options).Generate();

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

            return(client);
        }
コード例 #5
0
        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!!!");
        }