public async Task Should_Keep_Public_Key_After_Update_A_Expired_Jwk(string algorithm)
    {
        var alg         = Algorithm.Create(algorithm);
        var key         = new CryptographicKey(alg);
        var keyMaterial = new KeyMaterial(key);
        await _store.Store(keyMaterial);

        /*Remove private*/
        await _store.Revoke(keyMaterial);

        var dbKey = (await _store.GetLastKeys(5)).First(w => w.KeyId == keyMaterial.KeyId);

        dbKey.Type.Should().NotBeNullOrEmpty();

        var jsonWebKey = dbKey.GetSecurityKey();

        jsonWebKey.HasPrivateKey.Should().BeFalse();
        switch (jsonWebKey.Kty)
        {
        case JsonWebAlgorithmsKeyTypes.EllipticCurve:
            jsonWebKey.X.Should().NotBeNullOrEmpty();
            jsonWebKey.Y.Should().NotBeNullOrEmpty();
            break;

        case JsonWebAlgorithmsKeyTypes.RSA:
            jsonWebKey.N.Should().NotBeNullOrEmpty();
            jsonWebKey.E.Should().NotBeNullOrEmpty();
            break;

        case JsonWebAlgorithmsKeyTypes.Octet:
            jsonWebKey.K.Should().NotBeNullOrEmpty();
            break;
        }
    }
예제 #2
0
 public Task <ReadOnlyCollection <KeyMaterial> > GetLastKeys(int i)
 {
     return(_store.GetLastKeys(5));
 }