Package dev.sigstore.encryption
Class Keys
- java.lang.Object
-
- dev.sigstore.encryption.Keys
-
public class Keys extends java.lang.ObjectFor internal use. Key related utility functions.
-
-
Constructor Summary
Constructors Constructor Description Keys()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.security.PublicKeyconstructTufPublicKey(byte[] contents, java.lang.String scheme)Valid values for scheme are: ed25519 ecdsa-sha2-nistp256static java.security.PublicKeyparsePkcs1RsaPublicKey(byte[] contents)static java.security.PublicKeyparsePkixPublicKey(byte[] contents, java.lang.String algorithm)Takes a PKIX DER formatted public key in bytes and constructs aPublicKeywith it.static java.security.PublicKeyparsePublicKey(byte[] keyBytes)Takes a PEM formatted public key in bytes and constructs aPublicKeywith it.
-
-
-
Method Detail
-
parsePublicKey
public static java.security.PublicKey parsePublicKey(byte[] keyBytes) throws java.security.spec.InvalidKeySpecException, java.io.IOException, java.security.NoSuchAlgorithmExceptionTakes a PEM formatted public key in bytes and constructs aPublicKeywith it.This method supports the follow public key algorithms: RSA, EdDSA, EC.
- Throws:
java.security.spec.InvalidKeySpecException- if the PEM does not contain just one public key.java.security.NoSuchAlgorithmException- if the public key is using an unsupported algorithm.java.io.IOException
-
parsePkixPublicKey
public static java.security.PublicKey parsePkixPublicKey(byte[] contents, java.lang.String algorithm) throws java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecExceptionTakes a PKIX DER formatted public key in bytes and constructs aPublicKeywith it.This method is known to work with keys algorithms: RSA, EdDSA, EC.
- Parameters:
contents- the public key bytesalgorithm- the key algorithm- Returns:
- a PublicKey object
- Throws:
java.security.NoSuchAlgorithmException- if we don't support the scheme providedjava.security.spec.InvalidKeySpecException- if the public key material is invalid
-
parsePkcs1RsaPublicKey
public static java.security.PublicKey parsePkcs1RsaPublicKey(byte[] contents) throws java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException- Throws:
java.security.NoSuchAlgorithmExceptionjava.security.spec.InvalidKeySpecException
-
constructTufPublicKey
public static java.security.PublicKey constructTufPublicKey(byte[] contents, java.lang.String scheme) throws java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecExceptionValid values for scheme are:- Parameters:
contents- keyBytesscheme- signing scheme- Returns:
- java {link PublicKey}
- Throws:
java.security.NoSuchAlgorithmException- if we don't support the scheme providedjava.security.spec.InvalidKeySpecException- if the public key material is invalid- See Also:
- spec
-
-