| OLD | NEW |
| 1 /* crypto/uid.c */ | 1 /* |
| 2 * Poly1305 |
| 3 * |
| 4 * Created on: Jun, 2013 |
| 5 * Author: Elie Bursztein (elieb@google.com) |
| 6 * |
| 7 * Adapted from the estream code by D. Bernstein. |
| 8 */ |
| 2 /* ==================================================================== | 9 /* ==================================================================== |
| 3 * Copyright (c) 2001 The OpenSSL Project. All rights reserved. | 10 * Copyright (c) 2011-2013 The OpenSSL Project. All rights reserved. |
| 4 * | 11 * |
| 5 * Redistribution and use in source and binary forms, with or without | 12 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 13 * modification, are permitted provided that the following conditions |
| 7 * are met: | 14 * are met: |
| 8 * | 15 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 16 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 17 * notice, this list of conditions and the following disclaimer. |
| 11 * | 18 * |
| 12 * 2. Redistributions in binary form must reproduce the above copyright | 19 * 2. Redistributions in binary form must reproduce the above copyright |
| 13 * notice, this list of conditions and the following disclaimer in | 20 * notice, this list of conditions and the following disclaimer in |
| 14 * the documentation and/or other materials provided with the | 21 * the documentation and/or other materials provided with the |
| 15 * distribution. | 22 * distribution. |
| 16 * | 23 * |
| 17 * 3. All advertising materials mentioning features or use of this | 24 * 3. All advertising materials mentioning features or use of this |
| 18 * software must display the following acknowledgment: | 25 * software must display the following acknowledgment: |
| 19 * "This product includes software developed by the OpenSSL Project | 26 * "This product includes software developed by the OpenSSL Project |
| 20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | 27 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | 46 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
| 40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 47 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 49 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 50 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 52 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 53 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
| 47 * OF THE POSSIBILITY OF SUCH DAMAGE. | 54 * OF THE POSSIBILITY OF SUCH DAMAGE. |
| 48 * ==================================================================== | 55 * ==================================================================== |
| 49 * | |
| 50 * This product includes cryptographic software written by Eric Young | |
| 51 * (eay@cryptsoft.com). This product includes software written by Tim | |
| 52 * Hudson (tjh@cryptsoft.com). | |
| 53 * | |
| 54 */ | 56 */ |
| 55 | 57 |
| 56 #include <openssl/crypto.h> | 58 #ifndef HEADER_POLY1305_H_ |
| 59 #define HEADER_POLY1305_H_ |
| 60 |
| 61 #include <stdint.h> |
| 57 #include <openssl/opensslconf.h> | 62 #include <openssl/opensslconf.h> |
| 58 | 63 |
| 59 #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) | 64 #if defined(OPENSSL_NO_POLY1305) |
| 60 | 65 #error Poly1305 support is disabled. |
| 61 #include OPENSSL_UNISTD | |
| 62 | |
| 63 int OPENSSL_issetugid(void) | |
| 64 » { | |
| 65 » return issetugid(); | |
| 66 » } | |
| 67 | |
| 68 #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPEN
SSL_SYS_NETWARE) | |
| 69 | |
| 70 int OPENSSL_issetugid(void) | |
| 71 » { | |
| 72 » return 0; | |
| 73 » } | |
| 74 | |
| 75 #else | |
| 76 | |
| 77 #include OPENSSL_UNISTD | |
| 78 #include <sys/types.h> | |
| 79 | |
| 80 int OPENSSL_issetugid(void) | |
| 81 » { | |
| 82 » if (getuid() != geteuid()) return 1; | |
| 83 » if (getgid() != getegid()) return 1; | |
| 84 » return 0; | |
| 85 » } | |
| 86 #endif | 66 #endif |
| 87 | 67 |
| 68 typedef unsigned char poly1305_state[512]; |
| 88 | 69 |
| 70 /* poly1305_init sets up |state| so that it can be used to calculate an |
| 71 * authentication tag with the one-time key |key|. Note that |key| is a |
| 72 * one-time key and therefore there is no `reset' method because that would |
| 73 * enable several messages to be authenticated with the same key. */ |
| 74 extern void CRYPTO_poly1305_init(poly1305_state* state, |
| 75 const unsigned char key[32]); |
| 89 | 76 |
| 77 /* poly1305_update processes |in_len| bytes from |in|. It can be called zero or |
| 78 * more times after poly1305_init. */ |
| 79 extern void CRYPTO_poly1305_update(poly1305_state* state, |
| 80 const unsigned char *in, |
| 81 size_t in_len); |
| 82 |
| 83 /* poly1305_finish completes the poly1305 calculation and writes a 16 byte |
| 84 * authentication tag to |mac|. */ |
| 85 extern void CRYPTO_poly1305_finish(poly1305_state* state, |
| 86 unsigned char mac[16]); |
| 87 |
| 88 #endif /* HEADER_POLY1305_H_ */ |
| OLD | NEW |