Package org.cryptacular.ssh
Class SSHPublicKeyDecoder
java.lang.Object
org.cryptacular.ssh.SSHPublicKeyDecoder
Decodes public keys formatted as described in RFC 4253, Section 6.6, Public Key Algorithms.
RSA and DSS key formats are supported.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.bouncycastle.crypto.params.AsymmetricKeyParameterdecode(byte[] encoded) Produces an asymmetric key parameter from an encoded representation.org.bouncycastle.crypto.params.AsymmetricKeyParameterProduces an asymmetric key parameter from an encoded representation.private org.bouncycastle.crypto.params.AsymmetricKeyParameterdecodeInternal(byte[] encoded) Decode the supplied bytes for ssh-rsa and ssh-dss formats.private BigIntegerdecodeMPInt(ByteBuffer buffer) Decodes a mpint per RFC 4251, section 5 using the current position of the byte buffer.private StringdecodeString(ByteBuffer buffer) Decodes a string value per RFC 4251, section 5 using the current position of the byte buffer.static booleanisRFC4253EncodedPublicKey(byte[] key) Attempts to infer whether the encoded bytes contain an SSH public key.static booleanAttempts to infer whether the encoded bytes contain an SSH public key.
-
Constructor Details
-
SSHPublicKeyDecoder
public SSHPublicKeyDecoder()
-
-
Method Details
-
isRFC4253EncodedPublicKey
Attempts to infer whether the encoded bytes contain an SSH public key.- Parameters:
key- encoded key as a string- Returns:
- true if encoding format is probable, false otherwise
-
isRFC4253EncodedPublicKey
public static boolean isRFC4253EncodedPublicKey(byte[] key) Attempts to infer whether the encoded bytes contain an SSH public key.- Parameters:
key- encoded key as a byte array- Returns:
- true if encoding format is probable, false otherwise
-
decode
public org.bouncycastle.crypto.params.AsymmetricKeyParameter decode(byte[] encoded) Produces an asymmetric key parameter from an encoded representation.- Parameters:
encoded- encoded data- Returns:
- Decoded object.
-
decode
Produces an asymmetric key parameter from an encoded representation.- Parameters:
pubData- encoded data- Returns:
- Decoded object.
- Throws:
EncodingException- on encoding errors.
-
decodeInternal
private org.bouncycastle.crypto.params.AsymmetricKeyParameter decodeInternal(byte[] encoded) Decode the supplied bytes for ssh-rsa and ssh-dss formats.- Parameters:
encoded- to decode- Returns:
- decoded key
-
decodeString
Decodes a string value per RFC 4251, section 5 using the current position of the byte buffer.- Parameters:
buffer- buffered byte array to read from- Returns:
Stringrepresenting string
-
decodeMPInt
Decodes a mpint per RFC 4251, section 5 using the current position of the byte buffer.- Parameters:
buffer- buffered byte array to read from- Returns:
BigIntegerrepresenting mpint
-