Class SSHPublicKeyDecoder

java.lang.Object
org.cryptacular.ssh.SSHPublicKeyDecoder

public class SSHPublicKeyDecoder extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bouncycastle.crypto.params.AsymmetricKeyParameter
    decode(byte[] encoded)
    Produces an asymmetric key parameter from an encoded representation.
    org.bouncycastle.crypto.params.AsymmetricKeyParameter
    decode(String pubData)
    Produces an asymmetric key parameter from an encoded representation.
    private org.bouncycastle.crypto.params.AsymmetricKeyParameter
    decodeInternal(byte[] encoded)
    Decode the supplied bytes for ssh-rsa and ssh-dss formats.
    private BigInteger
    Decodes a mpint per RFC 4251, section 5 using the current position of the byte buffer.
    private String
    Decodes a string value per RFC 4251, section 5 using the current position of the byte buffer.
    static boolean
    Attempts to infer whether the encoded bytes contain an SSH public key.
    static boolean
    Attempts to infer whether the encoded bytes contain an SSH public key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SSHPublicKeyDecoder

      public SSHPublicKeyDecoder()
  • Method Details

    • isRFC4253EncodedPublicKey

      public static boolean isRFC4253EncodedPublicKey(String key)
      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

      public org.bouncycastle.crypto.params.AsymmetricKeyParameter decode(String pubData)
      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

      private String decodeString(ByteBuffer buffer)
      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:
      String representing string
    • decodeMPInt

      private BigInteger decodeMPInt(ByteBuffer buffer)
      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:
      BigInteger representing mpint