Interface SecretKeyRingProtector

    • Method Detail

      • getDecryptor

        @Nullable
        org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor getDecryptor​(Long keyId)
                                                                      throws org.bouncycastle.openpgp.PGPException
        Return a decryptor for the key of id keyId. This method returns null if the key is unprotected.
        Parameters:
        keyId - id of the key
        Returns:
        decryptor for the key
        Throws:
        org.bouncycastle.openpgp.PGPException
      • getEncryptor

        @Nullable
        org.bouncycastle.openpgp.operator.PBESecretKeyEncryptor getEncryptor​(Long keyId)
                                                                      throws org.bouncycastle.openpgp.PGPException
        Return an encryptor for the key of id keyId. This method returns null if the key is unprotected.
        Parameters:
        keyId - id of the key
        Returns:
        encryptor for the key
        Throws:
        org.bouncycastle.openpgp.PGPException - if the encryptor cannot be created for some reason
      • unlockEachKeyWith

        static SecretKeyRingProtector unlockEachKeyWith​(@Nonnull
                                                        Passphrase passphrase,
                                                        @Nonnull
                                                        org.bouncycastle.openpgp.PGPSecretKeyRing keys)
        Use the provided passphrase to lock/unlock all keys in the provided key ring. This protector will use the provided passphrase to lock/unlock all subkeys present in the provided keys object. For other keys that are not present in the ring, it will return null.
        Parameters:
        passphrase - passphrase
        keys - key ring
        Returns:
        protector
      • unlockSingleKeyWith

        static SecretKeyRingProtector unlockSingleKeyWith​(@Nonnull
                                                          Passphrase passphrase,
                                                          @Nonnull
                                                          org.bouncycastle.openpgp.PGPSecretKey key)
        Use the provided passphrase to lock/unlock only the provided (sub-)key. This protector will only return a non-null encryptor/decryptor based on the provided passphrase if getEncryptor(Long)/getDecryptor(Long) is getting called with the key-id of the provided key. Otherwise, this protector will always return null.
        Parameters:
        passphrase - passphrase
        key - key to lock/unlock
        Returns:
        protector