1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/sctp/src/netinet/sctp_sha1.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +/*- 1.5 + * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 1.6 + * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 1.7 + * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 1.8 + * 1.9 + * Redistribution and use in source and binary forms, with or without 1.10 + * modification, are permitted provided that the following conditions are met: 1.11 + * 1.12 + * a) Redistributions of source code must retain the above copyright notice, 1.13 + * this list of conditions and the following disclaimer. 1.14 + * 1.15 + * b) Redistributions in binary form must reproduce the above copyright 1.16 + * notice, this list of conditions and the following disclaimer in 1.17 + * the documentation and/or other materials provided with the distribution. 1.18 + * 1.19 + * c) Neither the name of Cisco Systems, Inc. nor the names of its 1.20 + * contributors may be used to endorse or promote products derived 1.21 + * from this software without specific prior written permission. 1.22 + * 1.23 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.24 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 1.25 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1.26 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 1.27 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 1.28 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 1.29 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 1.30 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 1.31 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 1.32 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 1.33 + * THE POSSIBILITY OF SUCH DAMAGE. 1.34 + */ 1.35 + 1.36 +#ifdef __FreeBSD__ 1.37 +#include <sys/cdefs.h> 1.38 +__FBSDID("$FreeBSD$"); 1.39 +#endif 1.40 + 1.41 + 1.42 +#ifndef __NETINET_SCTP_SHA1_H__ 1.43 +#define __NETINET_SCTP_SHA1_H__ 1.44 + 1.45 +#include <sys/types.h> 1.46 +#if defined(SCTP_USE_NSS_SHA1) 1.47 +#if defined(__Userspace_os_Darwin) 1.48 +/* The NSS sources require __APPLE__ to be defined. 1.49 + * XXX: Remove this ugly hack once the platform defines have been cleaned up. 1.50 + */ 1.51 +#define __APPLE__ 1.52 +#endif 1.53 +#include <pk11pub.h> 1.54 +#if defined(__Userspace_os_Darwin) 1.55 +#undef __APPLE__ 1.56 +#endif 1.57 +#elif defined(SCTP_USE_OPENSSL_SHA1) 1.58 +#include <openssl/sha.h> 1.59 +#endif 1.60 + 1.61 +struct sctp_sha1_context { 1.62 +#if defined(SCTP_USE_NSS_SHA1) 1.63 + struct PK11Context *pk11_ctx; 1.64 +#elif defined(SCTP_USE_OPENSSL_SHA1) 1.65 + SHA_CTX sha_ctx; 1.66 +#else 1.67 + unsigned int A; 1.68 + unsigned int B; 1.69 + unsigned int C; 1.70 + unsigned int D; 1.71 + unsigned int E; 1.72 + unsigned int H0; 1.73 + unsigned int H1; 1.74 + unsigned int H2; 1.75 + unsigned int H3; 1.76 + unsigned int H4; 1.77 + unsigned int words[80]; 1.78 + unsigned int TEMP; 1.79 + /* block I am collecting to process */ 1.80 + char sha_block[64]; 1.81 + /* collected so far */ 1.82 + int how_many_in_block; 1.83 + unsigned int running_total; 1.84 +#endif 1.85 +}; 1.86 + 1.87 +#if (defined(__APPLE__) && defined(KERNEL)) 1.88 +#ifndef _KERNEL 1.89 +#define _KERNEL 1.90 +#endif 1.91 +#endif 1.92 + 1.93 +#if defined(_KERNEL) || defined(__Userspace__) 1.94 + 1.95 +void sctp_sha1_init(struct sctp_sha1_context *); 1.96 +void sctp_sha1_update(struct sctp_sha1_context *, const unsigned char *, unsigned int); 1.97 +void sctp_sha1_final(unsigned char *, struct sctp_sha1_context *); 1.98 + 1.99 +#endif 1.100 +#endif