Class JcaTlsRawKeyCertificate
- java.lang.Object
-
- org.bouncycastle.tls.crypto.impl.jcajce.JcaTlsRawKeyCertificate
-
- All Implemented Interfaces:
TlsCertificate
- Direct Known Subclasses:
JcaTlsCertificate
public class JcaTlsRawKeyCertificate extends java.lang.Object implements TlsCertificate
Implementation class for a raw public key (RFC 7250) based on the JCA. The certificate is just a DER-encoded SubjectPublicKeyInfo, with no X.509 metadata: it has no serial number, signature algorithm, extensions or KeyUsage, so all signature/encryption uses are permitted by the key itself.This is the base class for
JcaTlsCertificate(an X.509 certificate is a SubjectPublicKeyInfo plus X.509 metadata); subclasses overridegetPublicKey(),getSubjectPublicKeyInfo(),supportsKeyUsageBit(int)and the X.509 accessors (getEncoded(),getExtension(ASN1ObjectIdentifier),getSerialNumber(),getSigAlgOID(),getSigAlgParams()) to source them from the certificate. This mirrors the lightweightBcTlsCertificate extends BcTlsRawKeyCertificatestructure.
-
-
Field Summary
Fields Modifier and Type Field Description protected JcaTlsCryptocryptoprotected org.bouncycastle.asn1.x509.SubjectPublicKeyInfokeyInfoprotected static intKU_CRL_SIGNprotected static intKU_DATA_ENCIPHERMENTprotected static intKU_DECIPHER_ONLYprotected static intKU_DIGITAL_SIGNATUREprotected static intKU_ENCIPHER_ONLYprotected static intKU_KEY_AGREEMENTprotected static intKU_KEY_CERT_SIGNprotected static intKU_KEY_ENCIPHERMENTprotected static intKU_NON_REPUDIATIONprotected javax.crypto.interfaces.DHPublicKeypubKeyDHprotected java.security.interfaces.ECPublicKeypubKeyECprotected java.security.PublicKeypubKeyRSA
-
Constructor Summary
Constructors Modifier Constructor Description protectedJcaTlsRawKeyCertificate(JcaTlsCrypto crypto)For subclasses (e.g.JcaTlsRawKeyCertificate(JcaTlsCrypto crypto, byte[] keyInfo)JcaTlsRawKeyCertificate(JcaTlsCrypto crypto, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo keyInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TlsCertificatecheckUsageInRole(int tlsCertificateRole)TlsEncryptorcreateEncryptor(int tlsCertificateRole)Return an encryptor based on the public key in this certificate.Tls13VerifiercreateVerifier(int signatureScheme)TlsVerifiercreateVerifier(short signatureAlgorithm)byte[]getEncoded()byte[]getExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier extensionOID)shortgetLegacySignatureAlgorithm()protected java.security.PublicKeygetPublicKey()java.math.BigIntegergetSerialNumber()java.lang.StringgetSigAlgOID()org.bouncycastle.asn1.ASN1EncodablegetSigAlgParams()protected org.bouncycastle.asn1.x509.SubjectPublicKeyInfogetSubjectPublicKeyInfo()protected booleanimplSupportsSignatureAlgorithm(short signatureAlgorithm)protected booleansupportsKeyUsageBit(int keyUsageBit)protected booleansupportsMLDSA(org.bouncycastle.asn1.ASN1ObjectIdentifier mlDsaAlgOid)protected booleansupportsRSA_PKCS1()protected booleansupportsRSA_PSS_PSS(short signatureAlgorithm)protected booleansupportsRSA_PSS_RSAE()booleansupportsSignatureAlgorithm(short signatureAlgorithm)booleansupportsSignatureAlgorithmCA(short signatureAlgorithm)protected booleansupportsSLHDSA(org.bouncycastle.asn1.ASN1ObjectIdentifier slhDsaAlgOid)protected voidvalidateKeyUsageBit(int keyUsageBit)protected voidvalidateMLDSA(org.bouncycastle.asn1.ASN1ObjectIdentifier mlDsaAlgOid)protected voidvalidateRSA_PKCS1()protected voidvalidateRSA_PSS_PSS(short signatureAlgorithm)protected voidvalidateRSA_PSS_RSAE()protected voidvalidateSLHDSA(org.bouncycastle.asn1.ASN1ObjectIdentifier slhDsaAlgOid)
-
-
-
Field Detail
-
KU_DIGITAL_SIGNATURE
protected static final int KU_DIGITAL_SIGNATURE
- See Also:
- Constant Field Values
-
KU_NON_REPUDIATION
protected static final int KU_NON_REPUDIATION
- See Also:
- Constant Field Values
-
KU_KEY_ENCIPHERMENT
protected static final int KU_KEY_ENCIPHERMENT
- See Also:
- Constant Field Values
-
KU_DATA_ENCIPHERMENT
protected static final int KU_DATA_ENCIPHERMENT
- See Also:
- Constant Field Values
-
KU_KEY_AGREEMENT
protected static final int KU_KEY_AGREEMENT
- See Also:
- Constant Field Values
-
KU_KEY_CERT_SIGN
protected static final int KU_KEY_CERT_SIGN
- See Also:
- Constant Field Values
-
KU_CRL_SIGN
protected static final int KU_CRL_SIGN
- See Also:
- Constant Field Values
-
KU_ENCIPHER_ONLY
protected static final int KU_ENCIPHER_ONLY
- See Also:
- Constant Field Values
-
KU_DECIPHER_ONLY
protected static final int KU_DECIPHER_ONLY
- See Also:
- Constant Field Values
-
crypto
protected final JcaTlsCrypto crypto
-
keyInfo
protected final org.bouncycastle.asn1.x509.SubjectPublicKeyInfo keyInfo
-
pubKeyDH
protected javax.crypto.interfaces.DHPublicKey pubKeyDH
-
pubKeyEC
protected java.security.interfaces.ECPublicKey pubKeyEC
-
pubKeyRSA
protected java.security.PublicKey pubKeyRSA
-
-
Constructor Detail
-
JcaTlsRawKeyCertificate
public JcaTlsRawKeyCertificate(JcaTlsCrypto crypto, byte[] keyInfo)
-
JcaTlsRawKeyCertificate
public JcaTlsRawKeyCertificate(JcaTlsCrypto crypto, org.bouncycastle.asn1.x509.SubjectPublicKeyInfo keyInfo)
-
JcaTlsRawKeyCertificate
protected JcaTlsRawKeyCertificate(JcaTlsCrypto crypto)
For subclasses (e.g.JcaTlsCertificate) that source the public key from elsewhere and overridegetPublicKey()/getSubjectPublicKeyInfo().
-
-
Method Detail
-
createEncryptor
public TlsEncryptor createEncryptor(int tlsCertificateRole) throws java.io.IOException
Description copied from interface:TlsCertificateReturn an encryptor based on the public key in this certificate.- Specified by:
createEncryptorin interfaceTlsCertificate- Parameters:
tlsCertificateRole-TlsCertificateRole- Returns:
- a TlsEncryptor based on this certificate's public key.
- Throws:
java.io.IOException
-
createVerifier
public TlsVerifier createVerifier(short signatureAlgorithm) throws java.io.IOException
- Specified by:
createVerifierin interfaceTlsCertificate- Parameters:
signatureAlgorithm-SignatureAlgorithm- Throws:
java.io.IOException
-
createVerifier
public Tls13Verifier createVerifier(int signatureScheme) throws java.io.IOException
- Specified by:
createVerifierin interfaceTlsCertificate- Parameters:
signatureScheme-SignatureScheme- Throws:
java.io.IOException
-
getEncoded
public byte[] getEncoded() throws java.io.IOException- Specified by:
getEncodedin interfaceTlsCertificate- Throws:
java.io.IOException
-
getExtension
public byte[] getExtension(org.bouncycastle.asn1.ASN1ObjectIdentifier extensionOID) throws java.io.IOException- Specified by:
getExtensionin interfaceTlsCertificate- Throws:
java.io.IOException
-
getSerialNumber
public java.math.BigInteger getSerialNumber()
- Specified by:
getSerialNumberin interfaceTlsCertificate
-
getSigAlgOID
public java.lang.String getSigAlgOID()
- Specified by:
getSigAlgOIDin interfaceTlsCertificate- Returns:
- the OID of this certificate's 'signatureAlgorithm', as a String.
-
getSigAlgParams
public org.bouncycastle.asn1.ASN1Encodable getSigAlgParams() throws java.io.IOException- Specified by:
getSigAlgParamsin interfaceTlsCertificate- Throws:
java.io.IOException
-
getLegacySignatureAlgorithm
public short getLegacySignatureAlgorithm() throws java.io.IOException- Specified by:
getLegacySignatureAlgorithmin interfaceTlsCertificate- Returns:
SignatureAlgorithm- Throws:
java.io.IOException
-
supportsSignatureAlgorithm
public boolean supportsSignatureAlgorithm(short signatureAlgorithm) throws java.io.IOException- Specified by:
supportsSignatureAlgorithmin interfaceTlsCertificate- Parameters:
signatureAlgorithm-SignatureAlgorithm- Returns:
- true if (and only if) this certificate can be used to verify the given signature algorithm.
- Throws:
java.io.IOException
-
supportsSignatureAlgorithmCA
public boolean supportsSignatureAlgorithmCA(short signatureAlgorithm) throws java.io.IOException- Specified by:
supportsSignatureAlgorithmCAin interfaceTlsCertificate- Throws:
java.io.IOException
-
checkUsageInRole
public TlsCertificate checkUsageInRole(int tlsCertificateRole) throws java.io.IOException
- Specified by:
checkUsageInRolein interfaceTlsCertificate- Parameters:
tlsCertificateRole-TlsCertificateRole- Throws:
java.io.IOException
-
implSupportsSignatureAlgorithm
protected boolean implSupportsSignatureAlgorithm(short signatureAlgorithm) throws java.io.IOException- Throws:
java.io.IOException
-
getPublicKey
protected java.security.PublicKey getPublicKey() throws java.io.IOException- Throws:
java.io.IOException
-
getSubjectPublicKeyInfo
protected org.bouncycastle.asn1.x509.SubjectPublicKeyInfo getSubjectPublicKeyInfo() throws java.io.IOException- Throws:
java.io.IOException
-
supportsKeyUsageBit
protected boolean supportsKeyUsageBit(int keyUsageBit)
-
supportsMLDSA
protected boolean supportsMLDSA(org.bouncycastle.asn1.ASN1ObjectIdentifier mlDsaAlgOid) throws java.io.IOException- Throws:
java.io.IOException
-
supportsRSA_PKCS1
protected boolean supportsRSA_PKCS1() throws java.io.IOException- Throws:
java.io.IOException
-
supportsRSA_PSS_PSS
protected boolean supportsRSA_PSS_PSS(short signatureAlgorithm) throws java.io.IOException- Throws:
java.io.IOException
-
supportsRSA_PSS_RSAE
protected boolean supportsRSA_PSS_RSAE() throws java.io.IOException- Throws:
java.io.IOException
-
supportsSLHDSA
protected boolean supportsSLHDSA(org.bouncycastle.asn1.ASN1ObjectIdentifier slhDsaAlgOid) throws java.io.IOException- Throws:
java.io.IOException
-
validateKeyUsageBit
protected void validateKeyUsageBit(int keyUsageBit) throws java.io.IOException- Throws:
java.io.IOException
-
validateMLDSA
protected void validateMLDSA(org.bouncycastle.asn1.ASN1ObjectIdentifier mlDsaAlgOid) throws java.io.IOException- Throws:
java.io.IOException
-
validateRSA_PKCS1
protected void validateRSA_PKCS1() throws java.io.IOException- Throws:
java.io.IOException
-
validateRSA_PSS_PSS
protected void validateRSA_PSS_PSS(short signatureAlgorithm) throws java.io.IOException- Throws:
java.io.IOException
-
validateRSA_PSS_RSAE
protected void validateRSA_PSS_RSAE() throws java.io.IOException- Throws:
java.io.IOException
-
validateSLHDSA
protected void validateSLHDSA(org.bouncycastle.asn1.ASN1ObjectIdentifier slhDsaAlgOid) throws java.io.IOException- Throws:
java.io.IOException
-
-