{
    "content": [
        {
            "type": "text",
            "text": "# Crypt::AuthEnc::EAX (perldoc)\n\n## NAME\n\nCrypt::AuthEnc::EAX - Authenticated encryption in EAX mode\n\n## SYNOPSIS\n\n### OO interface\nuse Crypt::AuthEnc::EAX;\n# encrypt and authenticate\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $ct = $ae->encryptadd('data1');\n$ct .= $ae->encryptadd('data2');\n$ct .= $ae->encryptadd('data3');\nmy $tag = $ae->encryptdone();\n# decrypt and verify\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $pt = $ae->decryptadd('ciphertext1');\n$pt .= $ae->decryptadd('ciphertext2');\n$pt .= $ae->decryptadd('ciphertext3');\nmy $tag = $ae->decryptdone();\ndie \"decrypt failed\" unless $tag eq $expectedtag;\n#or\nmy $result = $ae->decryptdone($expectedtag); # 0 or 1\n### functional interface\nuse Crypt::AuthEnc::EAX qw(eaxencryptauthenticate eaxdecryptverify);\nmy ($ciphertext, $tag) = eaxencryptauthenticate('AES', $key, $iv, $adata, $plaintext);\nmy $plaintext = eaxdecryptverify('AES', $key, $iv, $adata, $ciphertext, $tag);\n\n## DESCRIPTION\n\nEAX is a mode that requires a cipher, CTR and OMAC support and provides encryption and\nauthentication. It is initialized with a random IV that can be shared publicly, additional\nauthenticated data which can be fixed and public, and a random secret symmetric key.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **EXPORT**\n- **FUNCTIONS**\n- **METHODS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Crypt::AuthEnc::EAX",
        "section": "",
        "mode": "perldoc",
        "summary": "Crypt::AuthEnc::EAX - Authenticated encryption in EAX mode",
        "synopsis": "### OO interface\nuse Crypt::AuthEnc::EAX;\n# encrypt and authenticate\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $ct = $ae->encryptadd('data1');\n$ct .= $ae->encryptadd('data2');\n$ct .= $ae->encryptadd('data3');\nmy $tag = $ae->encryptdone();\n# decrypt and verify\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $pt = $ae->decryptadd('ciphertext1');\n$pt .= $ae->decryptadd('ciphertext2');\n$pt .= $ae->decryptadd('ciphertext3');\nmy $tag = $ae->decryptdone();\ndie \"decrypt failed\" unless $tag eq $expectedtag;\n#or\nmy $result = $ae->decryptdone($expectedtag); # 0 or 1\n### functional interface\nuse Crypt::AuthEnc::EAX qw(eaxencryptauthenticate eaxdecryptverify);\nmy ($ciphertext, $tag) = eaxencryptauthenticate('AES', $key, $iv, $adata, $plaintext);\nmy $plaintext = eaxdecryptverify('AES', $key, $iv, $adata, $ciphertext, $tag);",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 31,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "EXPORT",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 12,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 30,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Crypt::AuthEnc::EAX - Authenticated encryption in EAX mode\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "### OO interface\nuse Crypt::AuthEnc::EAX;\n\n# encrypt and authenticate\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $ct = $ae->encryptadd('data1');\n$ct .= $ae->encryptadd('data2');\n$ct .= $ae->encryptadd('data3');\nmy $tag = $ae->encryptdone();\n\n# decrypt and verify\nmy $ae = Crypt::AuthEnc::EAX->new(\"AES\", $key, $iv);\n$ae->adataadd('additionalauthenticateddata1');\n$ae->adataadd('additionalauthenticateddata2');\nmy $pt = $ae->decryptadd('ciphertext1');\n$pt .= $ae->decryptadd('ciphertext2');\n$pt .= $ae->decryptadd('ciphertext3');\nmy $tag = $ae->decryptdone();\ndie \"decrypt failed\" unless $tag eq $expectedtag;\n\n#or\nmy $result = $ae->decryptdone($expectedtag); # 0 or 1\n\n### functional interface\nuse Crypt::AuthEnc::EAX qw(eaxencryptauthenticate eaxdecryptverify);\n\nmy ($ciphertext, $tag) = eaxencryptauthenticate('AES', $key, $iv, $adata, $plaintext);\nmy $plaintext = eaxdecryptverify('AES', $key, $iv, $adata, $ciphertext, $tag);\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "EAX is a mode that requires a cipher, CTR and OMAC support and provides encryption and\nauthentication. It is initialized with a random IV that can be shared publicly, additional\nauthenticated data which can be fixed and public, and a random secret symmetric key.\n",
                "subsections": []
            },
            "EXPORT": {
                "content": "Nothing is exported by default.\n\nYou can export selected functions:\n\nuse Crypt::AuthEnc::EAX qw(eaxencryptauthenticate eaxdecryptverify);\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "eaxencryptauthenticate\nmy ($ciphertext, $tag) = eaxencryptauthenticate($cipher, $key, $iv, $adata, $plaintext);\n\n# $cipher .. 'AES' or name of any other cipher with 16-byte block len\n# $key ..... AES key of proper length (128/192/256bits)\n# $iv ...... unique initialization vector (no need to keep it secret)\n# $adata ... additional authenticated data\n\neaxdecryptverify\nmy $plaintext = eaxdecryptverify($cipher, $key, $iv, $adata, $ciphertext, $tag);\n# on error returns undef\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new\nmy $ae = Crypt::AuthEnc::EAX->new($cipher, $key, $iv);\n#or\nmy $ae = Crypt::AuthEnc::EAX->new($cipher, $key, $iv, $adata);\n\n# $cipher .. 'AES' or name of any other cipher with 16-byte block len\n# $key ..... AES key of proper length (128/192/256bits)\n# $iv ...... unique initialization vector (no need to keep it secret)\n# $adata ... additional authenticated data (optional)\n\nadataadd\n$ae->adataadd($adata);                        # can be called multiple times\n\nencryptadd\n$ciphertext = $ae->encryptadd($data);         # can be called multiple times\n\nencryptdone\n$tag = $ae->encryptdone();                    # returns $tag value\n\ndecryptadd\n$plaintext = $ae->decryptadd($ciphertext);    # can be called multiple times\n\ndecryptdone\nmy $tag = $ae->decryptdone;           # returns $tag value\n#or\nmy $result = $ae->decryptdone($tag);  # returns 1 (success) or 0 (failure)\n\nclone\nmy $aenew = $ae->clone;\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "*   CryptX, Crypt::AuthEnc::CCM, Crypt::AuthEnc::GCM, Crypt::AuthEnc::OCB\n\n*   <https://en.wikipedia.org/wiki/EAXmode>\n",
                "subsections": []
            }
        }
    }
}