Class PK11PrivKey

    • Field Detail

      • keyProxy

        protected org.mozilla.jss.pkcs11.KeyProxy keyProxy
    • Constructor Detail

      • PK11PrivKey

        protected PK11PrivKey​(byte[] pointer)
    • Method Detail

      • getOwningToken

        public CryptoToken getOwningToken()
        Returns a new CryptoToken where this key resides.
        Specified by:
        getOwningToken in interface PrivateKey
        Returns:
        The PK11Token that owns this key.
      • getKeyType

        public KeyType getKeyType()
      • getAlgorithm

        public java.lang.String getAlgorithm()
        Specified by:
        getAlgorithm in interface java.security.Key
      • getStrength

        public int getStrength()
        Returns the size in bits of the modulus of an RSA Private key. Returns -1 for other types of keys.
        Specified by:
        getStrength in interface PrivateKey
      • getPublicKey

        public PK11PubKey getPublicKey()
        Returns the corresponding public key from a private key instance.
      • fromPrivateKeyInfo

        public static PK11PrivKey fromPrivateKeyInfo​(java.security.spec.PKCS8EncodedKeySpec spec,
                                                     CryptoToken token)
                                              throws TokenException
        Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token. The key will be a temporary (session) key until it is imported into a KeyStore, at which point it will be made a permanent (token) object.
        Throws:
        TokenException
      • fromPrivateKeyInfo

        public static PK11PrivKey fromPrivateKeyInfo​(byte[] pki,
                                                     CryptoToken token)
                                              throws TokenException
        Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token. The key will be a temporary (session) key until it is imported into a KeyStore, at which point it will be made a permanent (token) object.
        Throws:
        TokenException
      • fromPrivateKeyInfo

        public static PK11PrivKey fromPrivateKeyInfo​(byte[] pki,
                                                     CryptoToken token,
                                                     byte[] publicValue)
                                              throws TokenException
        Imports a PrivateKeyInfo, storing it as a temporary PrivateKey on the given token. The key will be a temporary (session) key until it is imported into a KeyStore, at which point it will be made a permanent (token) object.
        Parameters:
        publicValue - An encoding of the public key, as used by the NSS pk11wrap code. Don't use this unless you know what you're doing.
        Throws:
        TokenException
      • getEncoded

        public byte[] getEncoded()
        Subclasses that support encoding can overload this method.
        Specified by:
        getEncoded in interface java.security.Key
      • getFormat

        public java.lang.String getFormat()
        Subclasses that support encoding can overload this method.
        Specified by:
        getFormat in interface java.security.Key
      • finalize

        public void finalize()
                      throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception