Пример #1
0
        public static JwtRsaKey genKey(string kid)
        {
            var rsa       = RSA.Create();
            var rsaParams = rsa.ExportParameters(true);
            var jwk       = new JwtRsaKey
            {
                kty = "RSA",
                use = "enc",
                kid = kid,
                e   = toB64(rsaParams.Exponent),
                m   = toB64(rsaParams.Modulus),
                d   = toB64(rsaParams.D),
                p   = toB64(rsaParams.P),
                q   = toB64(rsaParams.Q),
                dp  = toB64(rsaParams.DP),
                dq  = toB64(rsaParams.DQ),
                qi  = toB64(rsaParams.InverseQ)
            };

            return(jwk);
            //Console.WriteLine(JsonConvert.SerializeObject(jwk));
        }
Пример #2
0
 public static string encryptKey(JwtRsaKey key, Share[] sharesOfSecret)
 {
     return(Jose.JWT.Encode(key, joinShares(sharesOfSecret), JweAlgorithm.DIR, JweEncryption.A128CBC_HS256));
 }