OpenSSHPublicKeyUtil (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.crypto.util

## Class OpenSSHPublicKeyUtil

- java.lang.Object
- - org.bouncycastle.crypto.util.OpenSSHPublicKeyUtil

-     public class OpenSSHPublicKeyUtil
      extends java.lang.Object

  OpenSSHPublicKeyUtil utility classes for parsing OpenSSH public keys.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `encodePublicKey(AsymmetricKeyParameter cipherParameters)` Encode a public key from an AsymmetricKeyParameter instance.
    `static AsymmetricKeyParameter` | `parsePublicKey(byte[] encoded)` Parse a public key.
    `static AsymmetricKeyParameter` | `parsePublicKey(org.bouncycastle.crypto.util.SSHBuffer buffer)` Parse a public key from an SSHBuffer instance.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### parsePublicKey

          public static AsymmetricKeyParameter parsePublicKey(byte[] encoded)

      Parse a public key.

      This method accepts the bytes that are Base64 encoded in an OpenSSH public key file.

      Parameters:
        `encoded` - The key.
      Returns:
        An AsymmetricKeyParameter instance.

    - #### encodePublicKey

          public static byte[] encodePublicKey(AsymmetricKeyParameter cipherParameters)
                                        throws java.io.IOException

      Encode a public key from an AsymmetricKeyParameter instance.
      Parameters:
        `cipherParameters` - The key to encode.
      Returns:
        the key OpenSSH encoded.
      Throws:
        `java.io.IOException`

    - #### parsePublicKey

          public static AsymmetricKeyParameter parsePublicKey(org.bouncycastle.crypto.util.SSHBuffer buffer)

      Parse a public key from an SSHBuffer instance.
      Parameters:
        `buffer` - containing the SSH public key.
      Returns:
        A CipherParameters instance.