1/*- 2 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 3 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 4 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * a) Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * b) Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the distribution. 15 * 16 * c) Neither the name of Cisco Systems, Inc. nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#ifdef __FreeBSD__ 34#include <sys/cdefs.h> 35__FBSDID("$FreeBSD$"); 36#endif 37 38 39#ifndef __NETINET_SCTP_SHA1_H__ 40#define __NETINET_SCTP_SHA1_H__ 41 42#include <sys/types.h> 43#if defined(SCTP_USE_NSS_SHA1) 44#if defined(__Userspace_os_Darwin) 45/* The NSS sources require __APPLE__ to be defined. 46 * XXX: Remove this ugly hack once the platform defines have been cleaned up. 47 */ 48#define __APPLE__ 49#endif 50#include <pk11pub.h> 51#if defined(__Userspace_os_Darwin) 52#undef __APPLE__ 53#endif 54#elif defined(SCTP_USE_OPENSSL_SHA1) 55#include <openssl/sha.h> 56#endif 57 58struct sctp_sha1_context { 59#if defined(SCTP_USE_NSS_SHA1) 60 struct PK11Context *pk11_ctx; 61#elif defined(SCTP_USE_OPENSSL_SHA1) 62 SHA_CTX sha_ctx; 63#else 64 unsigned int A; 65 unsigned int B; 66 unsigned int C; 67 unsigned int D; 68 unsigned int E; 69 unsigned int H0; 70 unsigned int H1; 71 unsigned int H2; 72 unsigned int H3; 73 unsigned int H4; 74 unsigned int words[80]; 75 unsigned int TEMP; 76 /* block I am collecting to process */ 77 char sha_block[64]; 78 /* collected so far */ 79 int how_many_in_block; 80 unsigned int running_total; 81#endif 82}; 83 84#if (defined(__APPLE__) && defined(KERNEL)) 85#ifndef _KERNEL 86#define _KERNEL 87#endif 88#endif 89 90#if defined(_KERNEL) || defined(__Userspace__) 91 92void sctp_sha1_init(struct sctp_sha1_context *); 93void sctp_sha1_update(struct sctp_sha1_context *, const unsigned char *, unsigned int); 94void sctp_sha1_final(unsigned char *, struct sctp_sha1_context *); 95 96#endif 97#endif 98