Botan  1.11.15
src/lib/mac/poly1305/poly1305.h
Go to the documentation of this file.
00001 /*
00002 * Poly1305
00003 * (C) 2014 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_MAC_POLY1305_H__
00009 #define BOTAN_MAC_POLY1305_H__
00010 
00011 #include <botan/mac.h>
00012 #include <memory>
00013 
00014 namespace Botan {
00015 
00016 /**
00017 * DJB's Poly1305
00018 * Important note: each key can only be used once
00019 */
00020 class BOTAN_DLL Poly1305 : public MessageAuthenticationCode
00021    {
00022    public:
00023       std::string name() const override { return "Poly1305"; }
00024 
00025       MessageAuthenticationCode* clone() const { return new Poly1305; }
00026 
00027       void clear();
00028 
00029       size_t output_length() const { return 16; }
00030 
00031       Key_Length_Specification key_spec() const
00032          {
00033          return Key_Length_Specification(32);
00034          }
00035 
00036    private:
00037       void add_data(const byte[], size_t);
00038       void final_result(byte[]);
00039       void key_schedule(const byte[], size_t);
00040 
00041       secure_vector<u64bit> m_poly;
00042       secure_vector<byte> m_buf;
00043       size_t m_buf_pos = 0;
00044    };
00045 
00046 }
00047 
00048 #endif