Skip to content

Commit a5bb31e

Browse files
committed
feat: add various extensions to KeyType
1 parent cbfce51 commit a5bb31e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/KeyTypeExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ namespace Yubico.YubiKey.Cryptography;
1616

1717
public static class KeyTypeExtensions
1818
{
19-
public static string ToAlgorithmOid(this KeyType keyType) => Oids.GetOidsByKeyType(keyType).AlgorithmOid;
20-
public static string? ToCurveOid(this KeyType keyType) => Oids.GetOidsByKeyType(keyType).Curveoid;
2119
public static KeyDefinition GetKeyDefinition(this KeyType keyType) => KeyDefinitions.GetByKeyType(keyType);
20+
public static string GetAlgorithmOid(this KeyType keyType) => Oids.GetOidsByKeyType(keyType).AlgorithmOid;
21+
public static string? GetCurveOid(this KeyType keyType) => Oids.GetOidsByKeyType(keyType).Curveoid;
22+
public static int GetKeySizeBits(this KeyType keyType) => keyType.GetKeyDefinition().LengthInBits;
23+
public static int GetKeySizeBytes(this KeyType keyType) => keyType.GetKeyDefinition().LengthInBytes;
2224
public static bool IsCoseKey(this KeyType keyType) => keyType.GetKeyDefinition().CoseKeyDefinition != null;
2325
public static bool IsECDsa(this KeyType keyType) => keyType is KeyType.ECP256 or KeyType.ECP384 or KeyType.ECP521;
2426
public static bool IsCurve25519(this KeyType keyType) => keyType is KeyType.X25519 or KeyType.Ed25519;
2527
public static bool IsAsymmetric(this KeyType keyType) =>
2628
IsEllipticCurve(keyType) || IsRSA(keyType);
2729
public static bool IsSymmetric(this KeyType keyType) =>
2830
keyType is KeyType.TripleDES or KeyType.AES128 or KeyType.AES192 or KeyType.AES256;
29-
3031
public static bool IsEllipticCurve(this KeyType keyType) =>
3132
keyType is KeyType.ECP256 or KeyType.ECP384 or KeyType.ECP521 or KeyType.X25519 or KeyType.Ed25519;
32-
3333
public static bool IsRSA(this KeyType keyType) =>
3434
keyType is KeyType.RSA1024 or KeyType.RSA2048 or KeyType.RSA3072 or KeyType.RSA4096;
3535
}

0 commit comments

Comments
 (0)