Chacha20Poly1305 (Bouncy Castle Library 1.54 API Specification)
Date: 2015-12-29

org.bouncycastle.crypto.tls

## Class Chacha20Poly1305

- java.lang.Object
- - org.bouncycastle.crypto.tls.Chacha20Poly1305

- All Implemented Interfaces:
    TlsCipher

      public class Chacha20Poly1305
      extends java.lang.Object
      implements TlsCipher

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected TlsContext` | `context`
    `protected ChaChaEngine` | `decryptCipher`
    `protected ChaChaEngine` | `encryptCipher`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Chacha20Poly1305(TlsContext context)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected byte[]` | `calculateRecordMAC(KeyParameter macKey, byte[] additionalData, byte[] buf, int off, int len)`
    `byte[]` | `decodeCiphertext(long seqNo, short type, byte[] ciphertext, int offset, int len)`
    `byte[]` | `encodePlaintext(long seqNo, short type, byte[] plaintext, int offset, int len)`
    `protected byte[]` | `getAdditionalData(long seqNo, short type, int len)`
    `int` | `getPlaintextLimit(int ciphertextLimit)`
    `protected KeyParameter` | `initRecordMAC(ChaChaEngine cipher, boolean forEncryption, long seqNo)`
    `protected void` | `updateRecordMAC(Mac mac, byte[] buf, int off, int len)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### context

          protected TlsContext context

    - #### encryptCipher

          protected ChaChaEngine encryptCipher

    - #### decryptCipher

          protected ChaChaEngine decryptCipher

  - ### Constructor Detail

    - #### Chacha20Poly1305

          public Chacha20Poly1305(TlsContext context)
                           throws java.io.IOException

      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### getPlaintextLimit

          public int getPlaintextLimit(int ciphertextLimit)

      Specified by:
        `getPlaintextLimit` in interface `TlsCipher`

    - #### encodePlaintext

          public byte[] encodePlaintext(long seqNo,
                               short type,
                               byte[] plaintext,
                               int offset,
                               int len)
                                 throws java.io.IOException

      Specified by:
        `encodePlaintext` in interface `TlsCipher`
      Throws:
        `java.io.IOException`

    - #### decodeCiphertext

          public byte[] decodeCiphertext(long seqNo,
                                short type,
                                byte[] ciphertext,
                                int offset,
                                int len)
                                  throws java.io.IOException

      Specified by:
        `decodeCiphertext` in interface `TlsCipher`
      Throws:
        `java.io.IOException`

    - #### initRecordMAC

          protected KeyParameter initRecordMAC(ChaChaEngine cipher,
                                   boolean forEncryption,
                                   long seqNo)

    - #### calculateRecordMAC

          protected byte[] calculateRecordMAC(KeyParameter macKey,
                                  byte[] additionalData,
                                  byte[] buf,
                                  int off,
                                  int len)

    - #### updateRecordMAC

          protected void updateRecordMAC(Mac mac,
                             byte[] buf,
                             int off,
                             int len)

    - #### getAdditionalData

          protected byte[] getAdditionalData(long seqNo,
                                 short type,
                                 int len)
                                      throws java.io.IOException

      Throws:
        `java.io.IOException`