From bfbee931a91bfed96c1f1e058a9bae061af227f1 Mon Sep 17 00:00:00 2001 From: Elena Quijano Date: Thu, 15 Aug 2024 19:07:02 -0700 Subject: [PATCH 1/5] updated RSA key sizes in user manual files --- .../docs/users-manual/application-piv/apdu/auth-decrypt.md | 2 +- .../docs/users-manual/application-piv/apdu/auth-sign.md | 2 +- .../docs/users-manual/application-piv/apdu/generate-pair.md | 4 ++-- .../docs/users-manual/application-piv/apdu/import-asym.md | 4 ++-- .../docs/users-manual/application-piv/apdu/metadata.md | 6 ++---- .../docs/users-manual/application-piv/commands.md | 4 ++-- .../docs/users-manual/application-piv/public-keys.md | 6 ++++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-decrypt.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-decrypt.md index 12f83d5d..e70686a0 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-decrypt.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-decrypt.md @@ -20,7 +20,7 @@ limitations under the License. --> |:---:|:---:|:-----------:|:-------------:|:----------:|:-------------------------:|:--------:| | 00 | 87 | *algorithm* | *slot number* | *data len* | *encoded data to decrypt* | (absent) | -The *algorithm* is either `06` (RSA-1048) or `07` (RSA-2048). Note that it is not possible +The *algorithm* is either `06` (RSA-1048), `07` (RSA-2048), `08` (RSA 3072), or `09` (RSA 4096). Note that it is not possible to decrypt using ECC. The *slot number* can be the number of any slot that holds a private key, other than `F9`. diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-sign.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-sign.md index b1fc07f6..048ff378 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-sign.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-sign.md @@ -20,7 +20,7 @@ limitations under the License. --> |:---:|:---:|:-----------:|:-------------:|:----------:|:--------------------------------:|:--------:| | 00 | 87 | *algorithm* | *slot number* | *data len* | *encoded digest of data to sign* | (absent) | -The *algorithm* is either `06` (RSA-1048), `07` (RSA-2048), `11` (ECC-P256), or `14` +The *algorithm* is either `06` (RSA-1048), `07` (RSA-2048), `08` (RSA 3072), `09` (RSA 4096), `11` (ECC-P256), or `14` (ECC-P384). The *slot number* can be the number of any slot that holds a private key, other than `F9`. diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/generate-pair.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/generate-pair.md index 64cfb9f8..3de7a42a 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/generate-pair.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/generate-pair.md @@ -35,8 +35,8 @@ However, the YubiKey does not support that slot. The value for the "remaining bytes" field must be equal to the number of bytes that come after it. For example, if three bytes come after the "remaining bytes" field, the field's value must be 03. -There are only four choices for "alg" (algorithm and size): RSA-1024 (06), -RSA-2048 (07), ECC-P-256 (11), and ECC-P-384 (14). +There are six choices for "alg" (algorithm and size): RSA-1024 (06), +RSA-2048 (07), RSA 3072 (08), RSA 4096 (09), ECC-P-256 (11), and ECC-P-384 (14). Both the PIN policy and touch policy are optional. If either or both are not given, they will be default. The default for PIN is "once" and touch is "never". diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/import-asym.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/import-asym.md index c76a2269..4be530bc 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/import-asym.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/import-asym.md @@ -29,8 +29,8 @@ The slot number can be one of the following (hex values): F9 ``` -There are only four choices for "alg" (algorithm and size): RSA-1024 (06), -RSA-2048 (07), ECC-P-256 (11), and ECC-P-384 (14). +There are six choices for "alg" (algorithm and size): RSA-1024 (06), +RSA-2048 (07), RSA 3072 (08), RSA 4096 (09), ECC-P-256 (11), and ECC-P-384 (14). The key data to load is a set of TLV constructions. The L (length) is DER encoding format. The V is the integer in canonical form. If the key is an RSA private key, there diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/metadata.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/metadata.md index 698e9343..4db309d9 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/metadata.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/metadata.md @@ -41,10 +41,8 @@ rules. The values (V of TLV) are dependent on the tags, described in the table b Tag | Name | Meaning | Data | Slots :---: | :---: | :---: | :---: -01 | Algorithm| Algorithm/Type of the key | ff (PIN or PUK), 03 (Triple DES), 08 (AES-128),
0A (AES-192), 0C ( -AES-256),
06 (RSA-1024), 07 (RSA-2048),
11 (ECC-P256), or 14 (ECC-P384) | all slots -02 | Policy| PIN and touch policy | PIN: 0 (Default), 1 (Never),
2 (Once), 3 (Always)
Touch: 0 (Default), 1 ( -Never),
2 (Always), 3 (Cached) | 9a, 9b, 9c, 9d, 9e, f9, 82 - 95 +01 | Algorithm| Algorithm/Type of the key | ff (PIN or PUK), 03 (Triple DES), 08 (AES-128),
0A (AES-192), 0C (AES-256),
06 (RSA-1024), 07 (RSA-2048),
08 (RSA 3072), 09 (RSA 4096)
11 (ECC-P256), or 14 (ECC-P384) | all slots +02 | Policy| PIN and touch policy | PIN: 0 (Default), 1 (Never),
2 (Once), 3 (Always)
Touch: 0 (Default), 1 (Never),
2 (Always), 3 (Cached) | 9a, 9b, 9c, 9d, 9e, f9, 82 - 95 03 | Origin| Imported or generated | 1 (generated), 2 (imported) | 9a, 9c, 9d, 9e, f9, 82 - 95 04 | Public| Pub key partner to the pri key | DER encoding of public key | 9a, 9c, 9d, 9e, f9, 82 - 95 05 | Default| Whether PIN/PUK/Mgmt Key has default value | 01 (default) 00 (not default) | 80, 81, 9b diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/commands.md b/Yubico.YubiKey/docs/users-manual/application-piv/commands.md index 78866699..01821782 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/commands.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/commands.md @@ -147,7 +147,7 @@ PIV slots. #### Table 1: List of Metadata Elements | Name | Meaning | Data | Slots | | :-------: | :----------------------------------------: | :---------------------------------------------------------------------------------------------------------: | :-----------------------------: | -| Algorithm | Algorithm of the key | PIN, PUK, Triple DES, AES-128, AES-192, AES-256,
RSA-1024, RSA-2048, ECC-P256, or ECC-P384 | all slots | +| Algorithm | Algorithm of the key | PIN, PUK, Triple DES, AES-128, AES-192, AES-256,
RSA-1024, RSA-2048, RSA 3072, RSA 4096, ECC-P256, or ECC-P384 | all slots | | Policy | PIN and touch policy | PIN: Default, Never, Once, Always
Touch: Default, Never, Always, Cached | 9A, 9B, 9C, 9D, 9E, F9, 82 - 95 | | Origin | Imported or generated | imported/generated | 9A, 9C, 9D, 9E, F9, 82 - 95 | | Public | Pub key partner to the pri key | DER encoding of public key | 9A, 9C, 9D, 9E, F9, 82 - 95 | @@ -775,7 +775,7 @@ All YubiKeys with the PIV application. The management key, slot number, algorithm, key size, PIN policy, and touch policy. -The YubiKey supports RSA 1024 and 2048, along with ECC P-256 and P-384. +The YubiKey supports RSA 1024, 2048, 3072, and 4096 along with ECC P-256 and P-384. ### Output diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/public-keys.md b/Yubico.YubiKey/docs/users-manual/application-piv/public-keys.md index a71b849f..6be705e6 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/public-keys.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/public-keys.md @@ -82,14 +82,16 @@ will need to be able to "convert" between `SubjectPublicKeyInfo` and `PivPublicK When you generate a new key pair on the PIV application, you are given the public key. The key is returned as an instance of the `PivPublicKey` class. From that class you can obtain -all the information about the key. The object has a property for algorithm: +all the information about the key. The object has a property for the algorithm, which can include the following: * RSA 1024 * RSA 2048 +* RSA 3072 +* RSA 4096 * ECC P256 * ECC P384 -The object also has properties for +The object also has properties for: * PIV-standard encoding * YubiKey encoding. From 89706f7ed68af65cb32ee8c3c79534f1822cf07e Mon Sep 17 00:00:00 2001 From: Elena Quijano Date: Mon, 19 Aug 2024 17:19:22 -0700 Subject: [PATCH 2/5] updated RSA key info in API docs --- .../application-piv/attestation.md | 2 +- .../Commands/AuthenticateDecryptCommand.cs | 6 +++-- .../Commands/AuthenticateDecryptResponse.cs | 6 +++-- .../Piv/Commands/AuthenticateSignCommand.cs | 4 +++- .../Piv/Commands/AuthenticateSignResponse.cs | 6 +++-- .../Commands/ImportAsymmetricKeyCommand.cs | 2 +- .../YubiKey/Piv/PivAlgorithmExtensions.cs | 4 ++-- .../Yubico/YubiKey/Piv/PivRsaPrivateKey.cs | 8 ++++--- .../src/Yubico/YubiKey/Piv/PivRsaPublicKey.cs | 4 ++-- .../YubiKey/Piv/PivSession.Attestation.cs | 2 +- .../Yubico/YubiKey/Piv/PivSession.Crypto.cs | 23 ++++++------------- 11 files changed, 34 insertions(+), 33 deletions(-) diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/attestation.md b/Yubico.YubiKey/docs/users-manual/application-piv/attestation.md index be497d60..297c6336 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/attestation.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/attestation.md @@ -156,7 +156,7 @@ allows for it. Note that if you replace the Yubico key and cert, there is no way to recover these original values, they will be gone for good. So use this method with caution. -The replacement key must be either RSA-2048, ECC-P256, or ECC-P384, and there are some +The replacement key must be either RSA-2048, RSA-3072, RSA-4096, ECC-P256, or ECC-P384, and there are some restrictions on the certificate. YubiKeys before version 5 did allow 1024-bit RSA keys as attestation keys, but to make your application work for all YubiKeys, you should never use a 1024-bit RSA key as an attestation key. diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs index 44e7a9e9..c26734b3 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs @@ -58,7 +58,7 @@ namespace Yubico.YubiKey.Piv.Commands /// /// The caller supplies the data to decrypt. It must be a block the same size /// as the key. For an RSA-1024 key, the block must be 128 bytes, for an - /// RSA-2048 key, the block must be 256 bytes. If the actual data to decrypt + /// RSA-2048 key, the block must be 256 bytes, for an RSA-3072 key, the block must be 384 bytes, and for an RSA-4096 key, the block must be 512 bytes. If the actual data to decrypt /// is shorter, it must be provided with as many prepended 00 bytes as needed /// to make sure the block is the appropriate length. /// @@ -107,7 +107,9 @@ private AuthenticateDecryptCommand() /// /// If the key that will be used to decrypt is RSA-1024, then the data to /// decrypt must be 128 (1024 bits) bytes long. If the key is RSA-2048, - /// then the data must be 256 bytes (2048 bits) long. See also the User's + /// then the data must be 256 bytes (2048 bits) long. If the key is RSA-3072, + /// then the data must be 384 bytes (3072 bits) long. If the key is RSA-4096, + /// then the data must be 512 bytes (4096 bits) long. See also the User's /// Manual entry on /// decrypting /// in the PIV commands page. diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptResponse.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptResponse.cs index 87f2dc4d..7de9c0cf 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptResponse.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptResponse.cs @@ -25,8 +25,10 @@ namespace Yubico.YubiKey.Piv.Commands /// /// The data returned by GetData is a byte array, /// containing the decrypted data. The data will be the same size as the key. - /// That is, for a 1024-bit RSA key, the decrypted data is 128 bytes, and for - /// a 2048-bit key, the decrypted data is 256 bytes. + /// That is, for a 1024-bit RSA key, the decrypted data is 128 bytes, for + /// a 2048-bit key, the decrypted data is 256 bytes, for + /// a 3072-bit key, the decrypted data is 384 bytes, and for + /// a 4096-bit key, the decrypted data is 512 bytes. /// /// /// The data returned is almost certainly formatted, either using PKCS 1 v. diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignCommand.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignCommand.cs index 3470bc8f..e4ddce60 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignCommand.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignCommand.cs @@ -120,7 +120,9 @@ private AuthenticateSignCommand() /// The digest data is formatted if RSA. If the key that will be used to /// sign is RSA-1024, the the digest data must be 128 (1024 bits) bytes /// long. If the key is RSA-2048, then the digest data must be 256 bytes - /// (2048 bits) long. See also the User's Manual entry on + /// (2048 bits) long. If the key is RSA-3072, then the digest data must be 384 bytes + /// (3072 bits) long. If the key is RSA-4096, then the digest data must be 512 bytes + /// (4096 bits) long. See also the User's Manual entry on /// signing /// in the PIV commands page. /// diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignResponse.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignResponse.cs index afc97450..c0cdb3fe 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignResponse.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateSignResponse.cs @@ -29,8 +29,10 @@ namespace Yubico.YubiKey.Piv.Commands /// /// If the data had been signed by an RSA key, the data will be /// random-looking data the same size as the key. That is, for a 1024-bit RSA - /// key, the signature is 128 bytes, and for a 2048-bit key, the signature is - /// 256 bytes. + /// key, the signature is 128 bytes, for a 2048-bit key, the signature is + /// 256 bytes, for a 3072-bit key, the signature is + /// 384 bytes, and for a 4096-bit key, the signature is + /// 512 bytes. /// /// If the data had been signed by an ECC key, the signature will be the /// DER encoding of the following ASN.1 definition. diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/ImportAsymmetricKeyCommand.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/ImportAsymmetricKeyCommand.cs index d5cc536c..79f22c54 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/ImportAsymmetricKeyCommand.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/ImportAsymmetricKeyCommand.cs @@ -178,7 +178,7 @@ private ImportAsymmetricKeyCommand() /// /// /// The only possible private keys this command will accept are RSA-1024, - /// RSA-2048, ECC-P256, and ECC-P384. If you supply any other private + /// RSA-2048, RSA-3072, RSA-4096, ECC-P256, and ECC-P384. If you supply any other private /// key, the constructor will throw an exception. /// /// The slot number must be for a slot that holds an asymmetric key. See diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivAlgorithmExtensions.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivAlgorithmExtensions.cs index bd79fa9e..47fa619e 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivAlgorithmExtensions.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivAlgorithmExtensions.cs @@ -121,11 +121,11 @@ public static class PivAlgorithmExtensions /// Determines if the given algorithm is RSA. /// /// - /// The PivAlgorithm enum contains Rsa1024 and Rsa2048. But + /// The PivAlgorithm enum contains Rsa1024, Rsa2048, Rsa3072, and Rsa4096. But /// sometimes you just want to know if an algorithm is RSA or not. It /// would seem you would have to write code such as the following. /// - /// if ((algorithm == PivAlgorith.Rsa1024) || (algorithm == PivAlgorithm.Rsa2048)) + /// if ((algorithm == PivAlgorith.Rsa1024) || (algorithm == PivAlgorithm.Rsa2048) || (algorithm == PivAlgorithm.Rsa3072) || (algorithm == PivAlgorithm.Rsa4096)) /// /// /// With this extension, you can simply write. diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivRsaPrivateKey.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivRsaPrivateKey.cs index 9b5b257d..005d995e 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivRsaPrivateKey.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivRsaPrivateKey.cs @@ -36,10 +36,12 @@ namespace Yubico.YubiKey.Piv /// 03 length prime p Exponent dP || 04 length prime q Exponent dQ || /// /// - /// The YubiKey supports only 1024-bit and 2048-bit RSA keys. Each element in + /// The YubiKey supports 1024-bit, 2048-bit, 3072-bit, and 4096-bit RSA keys. Each element in /// the private key will be half that size. So for a 1024-bit RSA key pair, - /// the CRT components are each 512 bits (64 bytes) long, and for a 2048-bit - /// RSA key pair, the CRT components are each 1024 bits (128 bytes) long. + /// the CRT components are each 512 bits (64 bytes) long, for a 2048-bit + /// RSA key pair, the CRT components are each 1024 bits (128 bytes) long, for a 3072-bit + /// RSA key pair, the CRT components are each 1536 bits (192 bytes) long, and for a 4096-bit + /// RSA key pair, the CRT components are each 2048 bits (256 bytes) long. /// /// /// You can build an object from either the encoded private key, and then diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivRsaPublicKey.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivRsaPublicKey.cs index b73612b2..64e666ef 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivRsaPublicKey.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivRsaPublicKey.cs @@ -35,8 +35,8 @@ namespace Yubico.YubiKey.Piv /// . /// /// - /// The YubiKey supports only 1024-bit and 2048-bit RSA keys, which means - /// that the modulus must be exactly 128 or 256 byte long. + /// The YubiKey supports 1024-bit, 2048-bit, 3072-bit, and 4096-bit RSA keys, which means + /// that the modulus must be exactly 128, 256, 384, or 512 bytes long, respectively. /// /// /// The YubiKey supports only F4 (0x010001 = decimal 65,537) as the public diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Attestation.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Attestation.cs index e995414f..a59f67f2 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Attestation.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Attestation.cs @@ -238,7 +238,7 @@ public X509Certificate2 GetAttestationCertificate() /// /// /// There are limitations placed on the key and cert. The key must be - /// either RSA-2048, ECC-P256, or ECC-P384. The cert must be X.509, it + /// either RSA-2048, RSA-3072, RSA-4096, ECC-P256, or ECC-P384. The cert must be X.509, it /// must be version 2 or 3, the full DER encoding of the /// SubjectName must be fewer than 1029 bytes, and the total /// length of the certificate must be fewer than 3052 bytes. This method diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Crypto.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Crypto.cs index 58b0da5e..2e94aae6 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Crypto.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/PivSession.Crypto.cs @@ -68,26 +68,15 @@ public sealed partial class PivSession : IDisposable /// /// /// - /// If the key is RSA 1024, then the input must be exactly 128 bytes, + /// If the key is RSA 1024/2048/3072/4096, then the input must be exactly 128/256/384/512 bytes, /// otherwise the method will throw an exception. You can use the /// class to format the data. That /// class will be able to format the digest into either PKCS #1 v1.5 or a /// subset of PKCS #1 PSS. However, if that class does not support the /// exact format you want, you will have to write your own formatting - /// code and guarantee the input to this method is exactly 128 bytes - /// (prepend pad bytes of 00 until the length is exactly 128 if needed). - /// The signature will be a 128-byte block. - /// - /// - /// If the key is RSA 2048, then the input must be exactly 256 bytes, - /// otherwise the method will throw an exception. You can use the - /// class to format the data. That - /// class will be able to format the digest into either PKCS #1 v1.5 or a - /// subset of PKCS #1 PSS. However, if that class does not support the - /// exact format you want, you will have to write your own formatting - /// code and guarantee the input to this method is exactly 256 bytes - /// (prepend pad bytes of 00 until the length is exactly 256 if needed). - /// The signature will be a 256-byte block. + /// code and guarantee the input to this method is exactly 128/256/384/512 bytes + /// (prepend pad bytes of 00 until the length is exactly 128/256/384/512 if needed). + /// The signature will be a 128/256/384/512-byte block. /// /// /// Signing might require the PIN and/or touch, depending on the PIN and @@ -187,7 +176,9 @@ public byte[] Sign(byte slotNumber, ReadOnlyMemory dataToSign) /// /// /// If the key is RSA 1024, then the input must be exactly 128 bytes. If - /// the key is RSA 2048, then the input must be exactly 256 bytes. If the + /// the key is RSA 2048, then the input must be exactly 256 bytes. If + /// the key is RSA 3072, then the input must be exactly 384 bytes. If + /// the key is RSA 4096, then the input must be exactly 512 bytes. If the /// input data is not the correct length, the method will throw an /// exception. /// From 51174973bc9b39b52b703f52bb36dab11e39a8e2 Mon Sep 17 00:00:00 2001 From: Elena Quijano Date: Tue, 3 Sep 2024 13:33:49 -0700 Subject: [PATCH 3/5] changed wording --- .../Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs index c26734b3..7afe62fd 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/AuthenticateDecryptCommand.cs @@ -57,8 +57,7 @@ namespace Yubico.YubiKey.Piv.Commands /// /// /// The caller supplies the data to decrypt. It must be a block the same size - /// as the key. For an RSA-1024 key, the block must be 128 bytes, for an - /// RSA-2048 key, the block must be 256 bytes, for an RSA-3072 key, the block must be 384 bytes, and for an RSA-4096 key, the block must be 512 bytes. If the actual data to decrypt + /// as the key. For an RSA-1024/RSA-2048/RSA-3072/RSA-4096 key, the block must be 128/256/384/512 bytes. If the actual data to decrypt /// is shorter, it must be provided with as many prepended 00 bytes as needed /// to make sure the block is the appropriate length. /// From 97a542ff7e8d87f5bc7bc5f5394a34b58070054a Mon Sep 17 00:00:00 2001 From: Elena Quijano Date: Thu, 5 Sep 2024 14:59:37 -0700 Subject: [PATCH 4/5] fixed metadata placeholders --- .../docs/users-manual/application-piv/apdu/auth-decrypt.md | 2 +- .../docs/users-manual/application-piv/apdu/auth-sign.md | 2 +- .../docs/users-manual/application-piv/apdu/generate-pair.md | 2 +- .../docs/users-manual/application-piv/apdu/import-asym.md | 2 +- .../docs/users-manual/application-piv/apdu/metadata.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-decrypt.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-decrypt.md index e70686a0..6d0e2bc3 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-decrypt.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-decrypt.md @@ -20,7 +20,7 @@ limitations under the License. --> |:---:|:---:|:-----------:|:-------------:|:----------:|:-------------------------:|:--------:| | 00 | 87 | *algorithm* | *slot number* | *data len* | *encoded data to decrypt* | (absent) | -The *algorithm* is either `06` (RSA-1048), `07` (RSA-2048), `08` (RSA 3072), or `09` (RSA 4096). Note that it is not possible +The *algorithm* is either `06` (RSA-1048), `07` (RSA-2048), `05` (RSA 3072), or `16` (RSA 4096). Note that it is not possible to decrypt using ECC. The *slot number* can be the number of any slot that holds a private key, other than `F9`. diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-sign.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-sign.md index 048ff378..2851caa9 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-sign.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/auth-sign.md @@ -20,7 +20,7 @@ limitations under the License. --> |:---:|:---:|:-----------:|:-------------:|:----------:|:--------------------------------:|:--------:| | 00 | 87 | *algorithm* | *slot number* | *data len* | *encoded digest of data to sign* | (absent) | -The *algorithm* is either `06` (RSA-1048), `07` (RSA-2048), `08` (RSA 3072), `09` (RSA 4096), `11` (ECC-P256), or `14` +The *algorithm* is either `06` (RSA-1048), `07` (RSA-2048), `05` (RSA 3072), `16` (RSA 4096), `11` (ECC-P256), or `14` (ECC-P384). The *slot number* can be the number of any slot that holds a private key, other than `F9`. diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/generate-pair.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/generate-pair.md index 3de7a42a..72d411ed 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/generate-pair.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/generate-pair.md @@ -36,7 +36,7 @@ The value for the "remaining bytes" field must be equal to the number of bytes t bytes come after the "remaining bytes" field, the field's value must be 03. There are six choices for "alg" (algorithm and size): RSA-1024 (06), -RSA-2048 (07), RSA 3072 (08), RSA 4096 (09), ECC-P-256 (11), and ECC-P-384 (14). +RSA-2048 (07), RSA 3072 (05), RSA 4096 (16), ECC-P-256 (11), and ECC-P-384 (14). Both the PIN policy and touch policy are optional. If either or both are not given, they will be default. The default for PIN is "once" and touch is "never". diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/import-asym.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/import-asym.md index 4be530bc..15524bee 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/import-asym.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/import-asym.md @@ -30,7 +30,7 @@ F9 ``` There are six choices for "alg" (algorithm and size): RSA-1024 (06), -RSA-2048 (07), RSA 3072 (08), RSA 4096 (09), ECC-P-256 (11), and ECC-P-384 (14). +RSA-2048 (07), RSA 3072 (05), RSA 4096 (16), ECC-P-256 (11), and ECC-P-384 (14). The key data to load is a set of TLV constructions. The L (length) is DER encoding format. The V is the integer in canonical form. If the key is an RSA private key, there diff --git a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/metadata.md b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/metadata.md index 4db309d9..592b69cb 100644 --- a/Yubico.YubiKey/docs/users-manual/application-piv/apdu/metadata.md +++ b/Yubico.YubiKey/docs/users-manual/application-piv/apdu/metadata.md @@ -41,7 +41,7 @@ rules. The values (V of TLV) are dependent on the tags, described in the table b Tag | Name | Meaning | Data | Slots :---: | :---: | :---: | :---: -01 | Algorithm| Algorithm/Type of the key | ff (PIN or PUK), 03 (Triple DES), 08 (AES-128),
0A (AES-192), 0C (AES-256),
06 (RSA-1024), 07 (RSA-2048),
08 (RSA 3072), 09 (RSA 4096)
11 (ECC-P256), or 14 (ECC-P384) | all slots +01 | Algorithm| Algorithm/Type of the key | ff (PIN or PUK), 03 (Triple DES), 08 (AES-128),
0A (AES-192), 0C (AES-256),
06 (RSA-1024), 07 (RSA-2048),
05 (RSA 3072), 16 (RSA 4096)
11 (ECC-P256), or 14 (ECC-P384) | all slots 02 | Policy| PIN and touch policy | PIN: 0 (Default), 1 (Never),
2 (Once), 3 (Always)
Touch: 0 (Default), 1 (Never),
2 (Always), 3 (Cached) | 9a, 9b, 9c, 9d, 9e, f9, 82 - 95 03 | Origin| Imported or generated | 1 (generated), 2 (imported) | 9a, 9c, 9d, 9e, f9, 82 - 95 04 | Public| Pub key partner to the pri key | DER encoding of public key | 9a, 9c, 9d, 9e, f9, 82 - 95 From f1a0f9c5924c594da051d90a912e6fc334c6030c Mon Sep 17 00:00:00 2001 From: Elena Quijano Date: Thu, 5 Sep 2024 15:45:35 -0700 Subject: [PATCH 5/5] fixed sample code --- .../src/Yubico/YubiKey/Piv/Commands/GetMetadataCommand.cs | 2 +- .../src/Yubico/YubiKey/Piv/Commands/GetMetadataResponse.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataCommand.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataCommand.cs index e43633fc..b17be070 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataCommand.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataCommand.cs @@ -41,7 +41,7 @@ namespace Yubico.YubiKey.Piv.Commands /// GetMetadataResponse metadataResponse = connection.SendCommand(metadataCommand);
/// if (metadataResponse.Status == ResponseStatus.Success) /// { - /// PivKeyMetadata keyData = metadataResponse.GetData(); + /// PivMetadata keyData = metadataResponse.GetData(); /// } /// ///
diff --git a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataResponse.cs b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataResponse.cs index 23d3aedd..2a6a7451 100644 --- a/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataResponse.cs +++ b/Yubico.YubiKey/src/Yubico/YubiKey/Piv/Commands/GetMetadataResponse.cs @@ -38,7 +38,7 @@ namespace Yubico.YubiKey.Piv.Commands /// GetMetadataResponse metadataResponse = connection.SendCommand(metadataCommand);
/// if (metadataResponse.Status == ResponseStatus.Success) /// { - /// PivKeyMetadata keyData = metadataResponse.GetData(); + /// PivMetadata keyData = metadataResponse.GetData(); /// } /// ///