Interface IAsymCipher

  • All Known Implementing Classes:
    RsaCipher

    public interface IAsymCipher
    Interface for a public key cipher.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      org.bouncycastle.crypto.params.AsymmetricKeyParameter byteArrayToKey​(byte[] enckey)
      Converts a key from binary form.
      byte[] decryptAndVerify​(byte[] ciphertext, boolean verifywithforeign)
      Decrypts a message and verifies the signature.
      byte[] keyToByteArray​(org.bouncycastle.crypto.params.AsymmetricKeyParameter key)
      Converts a key to binary form.
      boolean setForeign​(byte[] foreignpublic)
      Sets the public key of the communication partner.
      byte[] signAndEncrypt​(byte[] msg, boolean encryptwithforeign)
      Signs a message and encrypts a message.
    • Method Detail

      • setForeign

        boolean setForeign​(byte[] foreignpublic)
        Sets the public key of the communication partner.
        Parameters:
        foreignpublic - The public key.
        Returns:
        False, if the key was invalid.
      • signAndEncrypt

        byte[] signAndEncrypt​(byte[] msg,
                              boolean encryptwithforeign)
        Signs a message and encrypts a message.
        Parameters:
        msg - The message.
        encryptwithforeign - True, if the foreign public key should be used for encryption, false, if the innate one should be used.
        Returns:
        The message with signature, encrypted.
      • decryptAndVerify

        byte[] decryptAndVerify​(byte[] ciphertext,
                                boolean verifywithforeign)
        Decrypts a message and verifies the signature.
        Parameters:
        msg - The signed and encrypted message.
        encryptwithforeign - True, if the foreign public key should be used for verification, false, if the innate one should be used.
        Returns:
        The message, null if verification failed.
      • keyToByteArray

        byte[] keyToByteArray​(org.bouncycastle.crypto.params.AsymmetricKeyParameter key)
        Converts a key to binary form.
        Parameters:
        key - The key.
        Returns:
        The binary form of the key.
      • byteArrayToKey

        org.bouncycastle.crypto.params.AsymmetricKeyParameter byteArrayToKey​(byte[] enckey)
        Converts a key from binary form.
        Parameters:
        enckey - The encoded key.
        Returns:
        The key.