1.1 --- a/epoc32/include/stdapis/openssl/pq_compat.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/openssl/pq_compat.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,151 @@
1.4 -pq_compat.h
1.5 +/* crypto/pqueue/pqueue_compat.h */
1.6 +/*
1.7 + * DTLS implementation written by Nagendra Modadugu
1.8 + * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
1.9 + */
1.10 +/* ====================================================================
1.11 + * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved.
1.12 + *
1.13 + * Redistribution and use in source and binary forms, with or without
1.14 + * modification, are permitted provided that the following conditions
1.15 + * are met:
1.16 + *
1.17 + * 1. Redistributions of source code must retain the above copyright
1.18 + * notice, this list of conditions and the following disclaimer.
1.19 + *
1.20 + * 2. Redistributions in binary form must reproduce the above copyright
1.21 + * notice, this list of conditions and the following disclaimer in
1.22 + * the documentation and/or other materials provided with the
1.23 + * distribution.
1.24 + *
1.25 + * 3. All advertising materials mentioning features or use of this
1.26 + * software must display the following acknowledgment:
1.27 + * "This product includes software developed by the OpenSSL Project
1.28 + * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
1.29 + *
1.30 + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
1.31 + * endorse or promote products derived from this software without
1.32 + * prior written permission. For written permission, please contact
1.33 + * openssl-core@OpenSSL.org.
1.34 + *
1.35 + * 5. Products derived from this software may not be called "OpenSSL"
1.36 + * nor may "OpenSSL" appear in their names without prior written
1.37 + * permission of the OpenSSL Project.
1.38 + *
1.39 + * 6. Redistributions of any form whatsoever must retain the following
1.40 + * acknowledgment:
1.41 + * "This product includes software developed by the OpenSSL Project
1.42 + * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
1.43 + *
1.44 + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
1.45 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.46 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1.47 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
1.48 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1.49 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1.50 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1.51 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.52 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.53 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1.54 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1.55 + * OF THE POSSIBILITY OF SUCH DAMAGE.
1.56 + * ====================================================================
1.57 + *
1.58 + * This product includes cryptographic software written by Eric Young
1.59 + * (eay@cryptsoft.com). This product includes software written by Tim
1.60 + * Hudson (tjh@cryptsoft.com).
1.61 + *
1.62 + */
1.63 +
1.64 +#if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
1.65 +#define SYMBIAN
1.66 +#endif
1.67 +
1.68 +#include "opensslconf.h"
1.69 +#include <openssl/bn.h>
1.70 +
1.71 +/*
1.72 + * The purpose of this header file is for supporting 64-bit integer
1.73 + * manipulation on 32-bit (and lower) machines. Currently the only
1.74 + * such environment is VMS, Utrix and those with smaller default integer
1.75 + * sizes than 32 bits. For all such environment, we fall back to using
1.76 + * BIGNUM. We may need to fine tune the conditions for systems that
1.77 + * are incorrectly configured.
1.78 + *
1.79 + * The only clients of this code are (1) pqueue for priority, and
1.80 + * (2) DTLS, for sequence number manipulation.
1.81 + */
1.82 +
1.83 +#if (defined(THIRTY_TWO_BIT) && !defined(BN_LLONG)) || defined(SIXTEEN_BIT) || defined(EIGHT_BIT)
1.84 +
1.85 +#define PQ_64BIT_IS_INTEGER 0
1.86 +#define PQ_64BIT_IS_BIGNUM 1
1.87 +
1.88 +#define PQ_64BIT BIGNUM
1.89 +#define PQ_64BIT_CTX BN_CTX
1.90 +
1.91 +#define pq_64bit_init(x) BN_init(x)
1.92 +#define pq_64bit_free(x) BN_free(x)
1.93 +
1.94 +#define pq_64bit_ctx_new(ctx) BN_CTX_new()
1.95 +#define pq_64bit_ctx_free(x) BN_CTX_free(x)
1.96 +
1.97 +#define pq_64bit_assign(x, y) BN_copy(x, y)
1.98 +#define pq_64bit_assign_word(x, y) BN_set_word(x, y)
1.99 +#define pq_64bit_gt(x, y) BN_ucmp(x, y) >= 1 ? 1 : 0
1.100 +#define pq_64bit_eq(x, y) BN_ucmp(x, y) == 0 ? 1 : 0
1.101 +#define pq_64bit_add_word(x, w) BN_add_word(x, w)
1.102 +#define pq_64bit_sub(r, x, y) BN_sub(r, x, y)
1.103 +#define pq_64bit_sub_word(x, w) BN_sub_word(x, w)
1.104 +#define pq_64bit_mod(r, x, n, ctx) BN_mod(r, x, n, ctx)
1.105 +
1.106 +#define pq_64bit_bin2num(bn, bytes, len) BN_bin2bn(bytes, len, bn)
1.107 +#define pq_64bit_num2bin(bn, bytes) BN_bn2bin(bn, bytes)
1.108 +#define pq_64bit_get_word(x) BN_get_word(x)
1.109 +#define pq_64bit_is_bit_set(x, offset) BN_is_bit_set(x, offset)
1.110 +#define pq_64bit_lshift(r, x, shift) BN_lshift(r, x, shift)
1.111 +#define pq_64bit_set_bit(x, num) BN_set_bit(x, num)
1.112 +#define pq_64bit_get_length(x) BN_num_bits((x))
1.113 +
1.114 +#else
1.115 +
1.116 +#define PQ_64BIT_IS_INTEGER 1
1.117 +#define PQ_64BIT_IS_BIGNUM 0
1.118 +
1.119 +#if defined(SIXTY_FOUR_BIT)
1.120 +#define PQ_64BIT BN_ULONG
1.121 +#define PQ_64BIT_PRINT "%lld"
1.122 +#elif defined(SIXTY_FOUR_BIT_LONG)
1.123 +#define PQ_64BIT BN_ULONG
1.124 +#define PQ_64BIT_PRINT "%ld"
1.125 +#elif defined(THIRTY_TWO_BIT)
1.126 +#define PQ_64BIT BN_ULLONG
1.127 +#define PQ_64BIT_PRINT "%lld"
1.128 +#endif
1.129 +
1.130 +#define PQ_64BIT_CTX void
1.131 +
1.132 +#define pq_64bit_init(x)
1.133 +#define pq_64bit_free(x)
1.134 +#define pq_64bit_ctx_new(ctx) (ctx)
1.135 +#define pq_64bit_ctx_free(x)
1.136 +
1.137 +#define pq_64bit_assign(x, y) (*(x) = *(y))
1.138 +#define pq_64bit_assign_word(x, y) (*(x) = y)
1.139 +#define pq_64bit_gt(x, y) (*(x) > *(y))
1.140 +#define pq_64bit_eq(x, y) (*(x) == *(y))
1.141 +#define pq_64bit_add_word(x, w) (*(x) = (*(x) + (w)))
1.142 +#define pq_64bit_sub(r, x, y) (*(r) = (*(x) - *(y)))
1.143 +#define pq_64bit_sub_word(x, w) (*(x) = (*(x) - (w)))
1.144 +#define pq_64bit_mod(r, x, n, ctx)
1.145 +
1.146 +#define pq_64bit_bin2num(num, bytes, len) bytes_to_long_long(bytes, num)
1.147 +#define pq_64bit_num2bin(num, bytes) long_long_to_bytes(num, bytes)
1.148 +#define pq_64bit_get_word(x) *(x)
1.149 +#define pq_64bit_lshift(r, x, shift) (*(r) = (*(x) << (shift)))
1.150 +#define pq_64bit_set_bit(x, num) do { \
1.151 + PQ_64BIT mask = 1; \
1.152 + mask = mask << (num); \
1.153 + *(x) |= mask; \
1.154 + } while(0)
1.155 +#endif /* OPENSSL_SYS_VMS */