Class RsaKeyGenSpec
java.lang.Object
zeroecho.core.alg.rsa.RsaKeyGenSpec
- All Implemented Interfaces:
Describable, AlgorithmKeySpec
Key generation specification for RSA key pairs.
This spec defines the modulus length and public exponent used when generating
an RSA key pair. It is passed to the algorithm’s key builder (see
RsaAlgorithm) to produce a KeyPair.
Parameters
- keySize: the RSA modulus size in bits. Must be at least 1024; typical secure values are 2048 or 3072, with 4096 used for high-security applications.
- publicExponent: the RSA public exponent. The common and recommended value is 65537 (F4), balancing security and performance.
Usage example
// Create a spec for a 2048-bit key with exponent 65537
RsaKeyGenSpec spec = RsaKeyGenSpec.rsa2048();
// Generate the key pair
KeyPair kp = rsaAlgorithm.asymmetricKeyPairGenerator(RsaKeyGenSpec.class)
.generateKeyPair(spec);
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionRsaKeyGenSpec(int keySize, int publicExponent) Constructs an RSA key generation spec with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionReturns a short description string.intkeySize()Returns the modulus length in bits.intReturns the public exponent.static RsaKeyGenSpecrsa2048()Convenience factory for a 2048-bit RSA spec with exponent 65537.static RsaKeyGenSpecrsa3072()Convenience factory for a 3072-bit RSA spec with exponent 65537.static RsaKeyGenSpecrsa4096()Convenience factory for a 4096-bit RSA spec with exponent 65537.
-
Constructor Details
-
RsaKeyGenSpec
public RsaKeyGenSpec(int keySize, int publicExponent) Constructs an RSA key generation spec with the given parameters.- Parameters:
keySize- modulus size in bits; must be at least 1024publicExponent- RSA public exponent, usually 65537- Throws:
IllegalArgumentException- ifkeySizeis smaller than 1024 or the exponent is not odd and at least 3
-
-
Method Details
-
keySize
public int keySize()Returns the modulus length in bits.- Returns:
- RSA modulus size
-
publicExponent
public int publicExponent()Returns the public exponent.- Returns:
- RSA public exponent (typically 65537)
-
rsa2048
Convenience factory for a 2048-bit RSA spec with exponent 65537.- Returns:
- new
RsaKeyGenSpecinstance for 2048/65537
-
rsa3072
Convenience factory for a 3072-bit RSA spec with exponent 65537.- Returns:
- new
RsaKeyGenSpecinstance for 3072/65537
-
rsa4096
Convenience factory for a 4096-bit RSA spec with exponent 65537.- Returns:
- new
RsaKeyGenSpecinstance for 4096/65537
-
description
Returns a short description string.Format is
"<keySize>:<publicExponent>", for example"2048:65537".- Specified by:
descriptionin interfaceDescribable- Returns:
- human-readable description of this spec
-