diff --git a/crypto/src/pqc/crypto/ntru/NtruKeyGenerationParameters.cs b/crypto/src/pqc/crypto/ntru/NtruKeyGenerationParameters.cs index df2a28bb0..09e802bf7 100644 --- a/crypto/src/pqc/crypto/ntru/NtruKeyGenerationParameters.cs +++ b/crypto/src/pqc/crypto/ntru/NtruKeyGenerationParameters.cs @@ -3,16 +3,21 @@ namespace Org.BouncyCastle.Pqc.Crypto.Ntru { + /// Key generation parameters for NTRU, binding a randomness source to an NTRU parameter set. public class NtruKeyGenerationParameters : KeyGenerationParameters { internal NtruParameters NtruParameters { get; } + /// Creates key generation parameters for the given NTRU parameter set. + /// The randomness source for key generation. + /// The NTRU parameter set to generate keys for. // We won't be using strength as the key length differs between public & private key public NtruKeyGenerationParameters(SecureRandom random, NtruParameters ntruParameters) : base(random, 1) { NtruParameters = ntruParameters; } + /// The NTRU parameter set keys will be generated for. public NtruParameters GetParameters() { return NtruParameters; diff --git a/crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs b/crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs index 4b570fdd9..04f114de2 100644 --- a/crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs +++ b/crypto/src/pqc/crypto/ntru/NtruKeyParameters.cs @@ -2,6 +2,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Ntru { + /// Base class for NTRU public and private keys, carrying the associated parameter set. public abstract class NtruKeyParameters : AsymmetricKeyParameter { @@ -13,8 +14,10 @@ internal NtruKeyParameters(bool privateKey, NtruParameters parameters) m_parameters = parameters; } + /// The NTRU parameter set this key belongs to. public NtruParameters Parameters => m_parameters; + /// Returns a copy of the raw key encoding. public abstract byte[] GetEncoded(); } } diff --git a/crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs b/crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs index 11d6a7237..e72f576a1 100644 --- a/crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs +++ b/crypto/src/pqc/crypto/ntru/NtruPublicKeyParameters.cs @@ -2,9 +2,21 @@ namespace Org.BouncyCastle.Pqc.Crypto.Ntru { + /// An NTRU public (encapsulation) key, represented by its raw byte encoding. + /// Instances are immutable. Create them via . public sealed class NtruPublicKeyParameters : NtruKeyParameters { + /// Creates an from its raw public key encoding. + /// The NTRU parameter set this key belongs to. + /// + /// The raw public key bytes; length must equal the parameter set's public key length. + /// + /// A new instance wrapping a defensive copy of . + /// + /// If or is null. + /// + /// If has the wrong length. public static NtruPublicKeyParameters FromEncoding(NtruParameters parameters, byte[] encoding) { #pragma warning disable CS0618 // Type or member is obsolete @@ -28,8 +40,10 @@ public NtruPublicKeyParameters(NtruParameters parameters, byte[] key) m_publicKey = (byte[])key.Clone(); } + /// Returns a copy of the raw public key encoding. public override byte[] GetEncoded() => (byte[])m_publicKey.Clone(); + /// Obsolete. Use instead. [Obsolete("Use 'GetEncoded' instead")] public byte[] PublicKey {