Class PrivateKey

java.lang.Object
com.codename1.security.Key
com.codename1.security.PrivateKey

public final class PrivateKey extends Key

A private key -- paired with a PublicKey to form a key pair. Carries the algorithm name ("RSA" or "EC") and the encoded key bytes.

For interop with PEM files (-----BEGIN PRIVATE KEY-----) feed the PKCS#8 DER bytes to fromPkcs8(String, byte[]).

  • Method Details

    • fromPkcs8

      public static PrivateKey fromPkcs8(String algorithm, byte[] pkcs8Der)
      Wraps a PKCS#8 DER blob. This is the format produced by openssl pkcs8 -topk8 -nocrypt.
    • rsa

      public static PrivateKey rsa(byte[] pkcs8Der)
      Convenience: build an RSA PrivateKey from a fromPkcs8(String, byte[]) PKCS#8 blob.