Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of wolfSSL by
poly1305.h
00001 /* poly1305.h 00002 * 00003 * Copyright (C) 2006-2016 wolfSSL Inc. 00004 * 00005 * This file is part of wolfSSL. 00006 * 00007 * wolfSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * wolfSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA 00020 */ 00021 00022 00023 #ifndef WOLF_CRYPT_POLY1305_H 00024 #define WOLF_CRYPT_POLY1305_H 00025 00026 #include <wolfssl/wolfcrypt/types.h> 00027 00028 #ifdef HAVE_POLY1305 00029 00030 #ifdef __cplusplus 00031 extern "C" { 00032 #endif 00033 00034 /* auto detect between 32bit / 64bit */ 00035 #if defined(__SIZEOF_INT128__) && defined(__LP64__) 00036 #define WC_HAS_SIZEOF_INT128_64BIT 00037 #endif 00038 00039 #if defined(_MSC_VER) && defined(_M_X64) 00040 #define WC_HAS_MSVC_64BIT 00041 #endif 00042 00043 #if (defined(__GNUC__) && defined(__LP64__) && \ 00044 ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)))) 00045 #define WC_HAS_GCC_4_4_64BIT 00046 #endif 00047 00048 #if (defined(WC_HAS_SIZEOF_INT128_64BIT) || defined(WC_HAS_MSVC_64BIT) || \ 00049 defined(WC_HAS_GCC_4_4_64BIT)) 00050 #define POLY130564 00051 #else 00052 #define POLY130532 00053 #endif 00054 00055 enum { 00056 POLY1305 = 7, 00057 POLY1305_BLOCK_SIZE = 16, 00058 POLY1305_DIGEST_SIZE = 16, 00059 }; 00060 00061 #define WC_POLY1305_PAD_SZ 16 00062 #define WC_POLY1305_MAC_SZ 16 00063 00064 /* Poly1305 state */ 00065 typedef struct Poly1305 { 00066 #if defined(POLY130564) 00067 word64 r[3]; 00068 word64 h[3]; 00069 word64 pad[2]; 00070 #else 00071 word32 r[5]; 00072 word32 h[5]; 00073 word32 pad[4]; 00074 #endif 00075 size_t leftover; 00076 unsigned char buffer[POLY1305_BLOCK_SIZE]; 00077 unsigned char final; 00078 } Poly1305; 00079 00080 00081 /* does init */ 00082 00083 WOLFSSL_API int wc_Poly1305SetKey(Poly1305* poly1305, const byte* key, word32 kySz); 00084 WOLFSSL_API int wc_Poly1305Update(Poly1305* poly1305, const byte*, word32); 00085 WOLFSSL_API int wc_Poly1305Final(Poly1305* poly1305, byte* tag); 00086 WOLFSSL_API int wc_Poly1305_MAC(Poly1305* ctx, byte* additional, word32 addSz, 00087 byte* input, word32 sz, byte* tag, word32 tagSz); 00088 #ifdef __cplusplus 00089 } /* extern "C" */ 00090 #endif 00091 00092 #endif /* HAVE_POLY1305 */ 00093 #endif /* WOLF_CRYPT_POLY1305_H */ 00094 00095
Generated on Tue Jul 12 2022 23:30:59 by
 1.7.2 
    