Skip to content

Commit a1f34af

Browse files
committed
chore(keys): cleanup
1 parent e4ba289 commit a1f34af

File tree

7 files changed

+17
-21
lines changed

7 files changed

+17
-21
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/AsnPrivateKeyDecoder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
using System;
1616
using System.Formats.Asn1;
1717
using System.Globalization;
18-
using System.Linq;
1918
using System.Security.Cryptography;
2019

2120
namespace Yubico.YubiKey.Cryptography;

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/Curve25519PrivateKey.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public sealed class Curve25519PrivateKey : PrivateKey
4545
/// </summary>
4646
/// <returns>A <see cref="ReadOnlyMemory{T}"/> containing the private scalar value.</returns>
4747
public ReadOnlyMemory<byte> PrivateKey => _privateKey;
48-
48+
4949
private Curve25519PrivateKey(
5050
ReadOnlyMemory<byte> privateKey,
5151
KeyType keyType)
@@ -61,9 +61,9 @@ private Curve25519PrivateKey(
6161

6262
privateKey.CopyTo(_privateKey);
6363
}
64-
64+
6565
/// <inheritdoc />
66-
public override byte[] ExportPkcs8PrivateKey()
66+
public override byte[] ExportPkcs8PrivateKey()
6767
{
6868
ThrowIfDisposed();
6969
return AsnPrivateKeyEncoder.EncodeToPkcs8(_privateKey, KeyType);
@@ -96,7 +96,7 @@ public static Curve25519PrivateKey CreateFromPkcs8(ReadOnlyMemory<byte> pkcs8Enc
9696
using var privateKeyHandle = new ZeroingMemoryHandle(privateKey);
9797
return new Curve25519PrivateKey(privateKeyHandle.Data, keyType);
9898
}
99-
99+
100100
/// <summary>
101101
/// Creates an instance of <see cref="Curve25519PrivateKey"/> from the given
102102
/// <paramref name="privateKey"/> and <paramref name="keyType"/>.

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/Curve25519PublicKey.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// limitations under the License.
1414

1515
using System;
16-
using System.Formats.Asn1;
1716
using System.Globalization;
1817
using System.Security.Cryptography;
1918

@@ -60,7 +59,7 @@ private Curve25519PublicKey(
6059

6160
publicPoint.CopyTo(_publicPoint);
6261
}
63-
62+
6463
/// <summary>
6564
/// Converts this public key to an ASN.1 DER encoded format (X.509 SubjectPublicKeyInfo).
6665
/// </summary>
@@ -73,7 +72,7 @@ public override byte[] ExportSubjectPublicKeyInfo() =>
7372
/// <summary>
7473
/// Creates a new instance of <see cref="Curve25519PublicKey"/> from a DER-encoded public key.
7574
/// </summary>
76-
/// <param name="encodedKey">
75+
/// <param name="subjectPublicKeyInfo">
7776
/// The DER-encoded public key.
7877
/// </param>
7978
/// <returns>

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/ECPrivateKey.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class ECPrivateKey : PrivateKey
3434
/// An <see cref="ECParameters"/> structure containing the curve parameters, key, and other
3535
/// cryptographic elements needed for EC operations.
3636
/// </value>
37-
public ECParameters Parameters { get;}
37+
public ECParameters Parameters { get; }
3838

3939
/// <summary>
4040
/// Gets the key definition associated with this RSA private key.
@@ -85,7 +85,7 @@ protected ECPrivateKey(ECDsa ecdsaObject)
8585
Parameters = ecdsaObject.ExportParameters(true);
8686
KeyDefinition = KeyDefinitions.GetByOid(Parameters.Curve.Oid);
8787
}
88-
88+
8989
/// <inheritdoc/>
9090
public override byte[] ExportPkcs8PrivateKey()
9191
{
@@ -116,18 +116,16 @@ public override void Clear()
116116
public static ECPrivateKey CreateFromPkcs8(ReadOnlyMemory<byte> encodedKey)
117117
{
118118
var parameters = AsnPrivateKeyDecoder.CreateECParameters(encodedKey);
119+
119120
return CreateFromParameters(parameters);
120121
}
121-
122-
#pragma warning disable CS0618 // Type or member is obsolete.
123122

124123
/// <summary>
125124
/// Creates an instance of <see cref="ECPrivateKey"/> from the given <paramref name="parameters"/>.
126125
/// </summary>
127126
/// <param name="parameters">The parameters to create the key from.</param>
128127
/// <returns>An instance of <see cref="ECPrivateKey"/>.</returns>
129128
public static ECPrivateKey CreateFromParameters(ECParameters parameters) => new(parameters);
130-
#pragma warning restore CS0618 // Type or member is obsolete
131129

132130
/// <summary>
133131
/// Creates a new instance of <see cref="ECPrivateKey"/> from the given

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/ECPublicKey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected ECPublicKey(ECDsa ecdsa)
9999

100100
/// <inheritdoc />
101101
public override byte[] ExportSubjectPublicKeyInfo() => AsnPublicKeyEncoder.EncodeToSubjectPublicKeyInfo(Parameters);
102-
102+
103103
/// <summary>
104104
/// Creates an instance of <see cref="ECPublicKey"/> from the given <paramref name="parameters"/>.
105105
/// </summary>

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/RSAPrivateKey.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public sealed class RSAPrivateKey : PrivateKey
4747
/// A <see cref="KeyDefinition"/> object that describes the key's properties, including its type and length.
4848
/// </value>
4949
public KeyDefinition KeyDefinition { get; }
50-
50+
5151
/// <inheritdoc />
5252
public override KeyType KeyType => KeyDefinition.KeyType;
5353

5454
private RSAPrivateKey(RSAParameters parameters)
5555
{
5656
int keyLengthBits = parameters.DP?.Length * 8 * 2 ?? 0;
57-
57+
5858
Parameters = parameters.NormalizeParameters();
5959
KeyDefinition = KeyDefinitions.GetByRSALength(keyLengthBits);
6060
}

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/RSAPublicKey.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public sealed class RSAPublicKey : PublicKey
3737
/// The parameters are used in cryptographic operations such as decryption and digital signature creation.
3838
/// </remarks>
3939
public RSAParameters Parameters { get; }
40-
40+
4141
/// <summary>
4242
/// Gets the key definition associated with this RSA private key.
4343
/// </summary>
4444
/// <value>
4545
/// A <see cref="KeyDefinition"/> object that describes the key's properties, including its type and length.
4646
/// </value>
47-
public KeyDefinition KeyDefinition { get; }
47+
public KeyDefinition KeyDefinition { get; }
4848

4949
/// <inheritdoc />
5050
public override KeyType KeyType => KeyDefinition.KeyType;
@@ -82,8 +82,8 @@ public override byte[] ExportSubjectPublicKeyInfo()
8282
/// </exception>
8383
public static RSAPublicKey CreateFromParameters(RSAParameters parameters)
8484
{
85-
if (parameters.D != null ||
86-
parameters.P != null ||
85+
if (parameters.D != null ||
86+
parameters.P != null ||
8787
parameters.Q != null ||
8888
parameters.DP != null ||
8989
parameters.DQ != null ||
@@ -92,7 +92,7 @@ public static RSAPublicKey CreateFromParameters(RSAParameters parameters)
9292
{
9393
throw new ArgumentException("Parameters must not contain private key data");
9494
}
95-
95+
9696
return new RSAPublicKey(parameters);
9797
}
9898

0 commit comments

Comments
 (0)