Class AESEngine

  • Direct Known Subclasses:
    CryptixAESEngine

    public class AESEngine
    extends Object
    Dummy wrapper for AES cipher operation. Warning - most methods UNUSED. See CryptixAESEngine overrides for the real thing.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AESEngine​(I2PAppContext ctx)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void decrypt​(byte[] payload, int payloadIndex, byte[] out, int outIndex, SessionKey sessionKey, byte[] iv, int length)
      Decrypt the data with the session key
      void decrypt​(byte[] payload, int payloadIndex, byte[] out, int outIndex, SessionKey sessionKey, byte[] iv, int ivOffset, int length)
      Decrypt the data with the session key.
      void decryptBlock​(byte[] payload, int inIndex, SessionKey sessionKey, byte[] rv, int outIndex)
      This just copies payload to rv, see extension for the real thing.
      void encrypt​(byte[] payload, int payloadIndex, byte[] out, int outIndex, SessionKey sessionKey, byte[] iv, int length)
      Encrypt the payload with the session key
      void encrypt​(byte[] payload, int payloadIndex, byte[] out, int outIndex, SessionKey sessionKey, byte[] iv, int ivOffset, int length)
      Encrypt the payload with the session key.
      void encryptBlock​(byte[] payload, int inIndex, SessionKey sessionKey, byte[] out, int outIndex)
      This just copies payload to out, see extension for the real thing.
      static byte[] getPadding​(I2PAppContext context, int curSize, long minPaddedSize)
      Return random bytes for padding the data to a mod 16 size so that it is at least minPaddedSize Public for ElGamalAESEngine.
      static int getPaddingSize​(int curSize, long minPaddedSize)
      Return size for padding the data to a mod 16 size so that it is at least minPaddedSize Public for ElGamalAESEngine.
      byte[] safeDecrypt​(byte[] payload, SessionKey sessionKey, byte[] iv)
      Deprecated.
      unused
      byte[] safeEncrypt​(byte[] payload, SessionKey sessionKey, byte[] iv, int paddedSize)
      Deprecated.
      unused
    • Method Detail

      • encrypt

        public void encrypt​(byte[] payload,
                            int payloadIndex,
                            byte[] out,
                            int outIndex,
                            SessionKey sessionKey,
                            byte[] iv,
                            int length)
        Encrypt the payload with the session key
        Parameters:
        payload - data to be encrypted
        payloadIndex - index into the payload to start encrypting
        out - where to store the result
        outIndex - where in out to start writing
        sessionKey - private esession key to encrypt to
        iv - IV for CBC, must be 16 bytes
        length - how much data to encrypt
      • encrypt

        public void encrypt​(byte[] payload,
                            int payloadIndex,
                            byte[] out,
                            int outIndex,
                            SessionKey sessionKey,
                            byte[] iv,
                            int ivOffset,
                            int length)
        Encrypt the payload with the session key. This just copies payload to out, see extension for the real thing.
        Parameters:
        payload - data to be encrypted
        payloadIndex - index into the payload to start encrypting
        out - where to store the result
        outIndex - where in out to start writing
        sessionKey - private esession key to encrypt to
        iv - IV for CBC
        length - how much data to encrypt
      • safeEncrypt

        @Deprecated
        public byte[] safeEncrypt​(byte[] payload,
                                  SessionKey sessionKey,
                                  byte[] iv,
                                  int paddedSize)
        Deprecated.
        unused
        Encrypt the SHA-256 Hash of the IV, the 4 byte length, and the payload, with random padding up to the paddedSize, rounded up to the next multiple of 16.
        Parameters:
        paddedSize - minimum size of the output
        iv - IV for CBC, must be 16 bytes
        Returns:
        null on error
      • safeDecrypt

        @Deprecated
        public byte[] safeDecrypt​(byte[] payload,
                                  SessionKey sessionKey,
                                  byte[] iv)
        Deprecated.
        unused
        See safeEncrypt() for description. WARNING - no check for maximum length here, OOM DOS possible, fix it if you're going to use this.
        Parameters:
        iv - IV for CBC, must be 16 bytes
        Returns:
        null on error
      • decrypt

        public void decrypt​(byte[] payload,
                            int payloadIndex,
                            byte[] out,
                            int outIndex,
                            SessionKey sessionKey,
                            byte[] iv,
                            int length)
        Decrypt the data with the session key
        Parameters:
        payload - data to be decrypted
        payloadIndex - index into the payload to start decrypting
        out - where to store the cleartext
        outIndex - where in out to start writing
        sessionKey - private session key to decrypt to
        iv - IV for CBC
        length - how much data to decrypt
      • decrypt

        public void decrypt​(byte[] payload,
                            int payloadIndex,
                            byte[] out,
                            int outIndex,
                            SessionKey sessionKey,
                            byte[] iv,
                            int ivOffset,
                            int length)
        Decrypt the data with the session key. This just copies payload to out, see extension for the real thing.
        Parameters:
        payload - data to be decrypted
        payloadIndex - index into the payload to start decrypting
        out - where to store the cleartext
        outIndex - where in out to start writing
        sessionKey - private session key to decrypt to
        iv - IV for CBC
        length - how much data to decrypt
      • encryptBlock

        public void encryptBlock​(byte[] payload,
                                 int inIndex,
                                 SessionKey sessionKey,
                                 byte[] out,
                                 int outIndex)
        This just copies payload to out, see extension for the real thing.
        Parameters:
        sessionKey - unused
      • decryptBlock

        public void decryptBlock​(byte[] payload,
                                 int inIndex,
                                 SessionKey sessionKey,
                                 byte[] rv,
                                 int outIndex)
        This just copies payload to rv, see extension for the real thing.
        Parameters:
        payload - encrypted data
        sessionKey - private session key
      • getPadding

        public static final byte[] getPadding​(I2PAppContext context,
                                              int curSize,
                                              long minPaddedSize)
        Return random bytes for padding the data to a mod 16 size so that it is at least minPaddedSize Public for ElGamalAESEngine. Not a public API, not for external use.
        Since:
        0.9.38 moved from ElGamalAESEngine
      • getPaddingSize

        public static final int getPaddingSize​(int curSize,
                                               long minPaddedSize)
        Return size for padding the data to a mod 16 size so that it is at least minPaddedSize Public for ElGamalAESEngine. Not a public API, not for external use.
        Since:
        0.9.38 moved from ElGamalAESEngine