Class AESEngine

java.lang.Object
net.i2p.crypto.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.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final I2PAppContext
     
    protected final Log
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    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 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.
    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.
    byte[]
    safeDecrypt(byte[] payload, SessionKey sessionKey, byte[] iv)
    Deprecated.
    unused
    byte[]
    safeEncrypt(byte[] payload, SessionKey sessionKey, byte[] iv, int paddedSize)
    Deprecated.
    unused

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _log

      protected final Log _log
    • _context

      protected final I2PAppContext _context
  • Constructor Details

  • Method Details

    • 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:
      iv - IV for CBC, must be 16 bytes
      paddedSize - minimum size of the output
      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