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.
poly1305.h
00001 /* poly1305.h 00002 * 00003 * Copyright (C) 2006-2017 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 \file wolfssl/wolfcrypt/poly1305.h 00024 */ 00025 00026 #ifndef WOLF_CRYPT_POLY1305_H 00027 #define WOLF_CRYPT_POLY1305_H 00028 00029 #include <wolfcrypt/types.h> 00030 00031 #ifdef HAVE_POLY1305 00032 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif 00036 00037 /* auto detect between 32bit / 64bit */ 00038 #if defined(__SIZEOF_INT128__) && defined(__LP64__) 00039 #define WC_HAS_SIZEOF_INT128_64BIT 00040 #endif 00041 00042 #if defined(_MSC_VER) && defined(_M_X64) 00043 #define WC_HAS_MSVC_64BIT 00044 #endif 00045 00046 #if (defined(__GNUC__) && defined(__LP64__) && \ 00047 ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)))) 00048 #define WC_HAS_GCC_4_4_64BIT 00049 #endif 00050 00051 #ifdef USE_INTEL_SPEEDUP 00052 #elif (defined(WC_HAS_SIZEOF_INT128_64BIT) || defined(WC_HAS_MSVC_64BIT) || \ 00053 defined(WC_HAS_GCC_4_4_64BIT)) 00054 #define POLY130564 00055 #else 00056 #define POLY130532 00057 #endif 00058 00059 enum { 00060 POLY1305 = 7, 00061 POLY1305_BLOCK_SIZE = 16, 00062 POLY1305_DIGEST_SIZE = 16, 00063 }; 00064 00065 #define WC_POLY1305_PAD_SZ 16 00066 #define WC_POLY1305_MAC_SZ 16 00067 00068 /* Poly1305 state */ 00069 typedef struct Poly1305 { 00070 #ifdef USE_INTEL_SPEEDUP 00071 word64 r[3]; 00072 word64 h[3]; 00073 word64 pad[2]; 00074 word64 hh[20]; 00075 word32 r1[8]; 00076 word32 r2[8]; 00077 word32 r3[8]; 00078 word32 r4[8]; 00079 word64 hm[16]; 00080 unsigned char buffer[8*POLY1305_BLOCK_SIZE]; 00081 size_t leftover; 00082 unsigned char finished; 00083 unsigned char started; 00084 #else 00085 #if defined(POLY130564) 00086 word64 r[3]; 00087 word64 h[3]; 00088 word64 pad[2]; 00089 #else 00090 word32 r[5]; 00091 word32 h[5]; 00092 word32 pad[4]; 00093 #endif 00094 size_t leftover; 00095 unsigned char buffer[POLY1305_BLOCK_SIZE]; 00096 unsigned char finished; 00097 #endif 00098 } Poly1305; 00099 00100 /* does init */ 00101 00102 WOLFSSL_API int wc_Poly1305SetKey(Poly1305* poly1305, const byte* key, 00103 word32 kySz); 00104 WOLFSSL_API int wc_Poly1305Update(Poly1305* poly1305, const byte*, word32); 00105 WOLFSSL_API int wc_Poly1305Final(Poly1305* poly1305, byte* tag); 00106 WOLFSSL_API int wc_Poly1305_MAC(Poly1305* ctx, byte* additional, word32 addSz, 00107 byte* input, word32 sz, byte* tag, word32 tagSz); 00108 #ifdef __cplusplus 00109 } /* extern "C" */ 00110 #endif 00111 00112 #endif /* HAVE_POLY1305 */ 00113 #endif /* WOLF_CRYPT_POLY1305_H */ 00114 00115
Generated on Tue Jul 12 2022 16:58:06 by
1.7.2