Importing crypto libraries
- crypto/external/bsd/heimdal - crypto/external/bsd/libsaslc - crypto/external/bsd/netpgp - crypto/external/bsd/openssl Change-Id: I91dbf05f33e637edf5b9bb408d5baddd7ba8cf75
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
LIB=netbn
|
||||
SRCS= bignum.c digest.c misc.c rand.c
|
||||
SRCS+= stubs.c
|
||||
MKMAN=no
|
||||
WARNS=4
|
||||
CPPFLAGS+=-I${EXTDIST}
|
||||
|
||||
INCS=bn.h digest.h
|
||||
INCSDIR=/usr/include/netpgp
|
||||
|
||||
EXTDIST= ${.CURDIR}/../cipher
|
||||
|
||||
.include <bsd.lib.mk>
|
||||
+5637
File diff suppressed because it is too large
Load Diff
+146
@@ -0,0 +1,146 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef FAUXBN_H_
|
||||
#define FAUXBN_H_ 20100108
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _KERNEL
|
||||
# include <inttypes.h>
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef __BEGIN_DECLS
|
||||
# if defined(__cplusplus)
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
# else
|
||||
# define __BEGIN_DECLS
|
||||
# define __END_DECLS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/* should be 32bit on ILP32, 64bit on LP64 */
|
||||
typedef unsigned long mp_digit;
|
||||
typedef uint64_t mp_word;
|
||||
|
||||
/* multi-precision integer */
|
||||
typedef struct mp_int {
|
||||
mp_digit *dp; /* array of digits */
|
||||
int used; /* # of digits used */
|
||||
int alloc; /* # of digits allocated */
|
||||
int sign; /* non-zero if negative */
|
||||
} mp_int;
|
||||
|
||||
#define BIGNUM mp_int
|
||||
#define BN_ULONG mp_digit
|
||||
|
||||
/* a "context" of mp integers - never really used */
|
||||
typedef struct bn_ctx_t {
|
||||
size_t count;
|
||||
size_t arraysize;
|
||||
BIGNUM **v;
|
||||
} BN_CTX;
|
||||
|
||||
#define MP_LT -1
|
||||
#define MP_EQ 0
|
||||
#define MP_GT 1
|
||||
|
||||
#define MP_ZPOS 0
|
||||
#define MP_NEG 1
|
||||
|
||||
#define MP_OKAY 0
|
||||
#define MP_MEM -2
|
||||
#define MP_VAL -3
|
||||
#define MP_RANGE MP_VAL
|
||||
|
||||
/*********************************/
|
||||
|
||||
#define BN_is_negative(x) ((x)->sign == MP_NEG)
|
||||
#define BN_is_zero(a) (((a)->used == 0) ? 1 : 0)
|
||||
#define BN_is_odd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? 1 : 0)
|
||||
#define BN_is_even(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? 1 : 0)
|
||||
|
||||
BIGNUM *BN_new(void);
|
||||
BIGNUM *BN_dup(const BIGNUM */*a*/);
|
||||
int BN_copy(BIGNUM */*b*/, const BIGNUM */*a*/);
|
||||
|
||||
void BN_init(BIGNUM */*a*/);
|
||||
void BN_free(BIGNUM */*a*/);
|
||||
void BN_clear(BIGNUM */*a*/);
|
||||
void BN_clear_free(BIGNUM */*a*/);
|
||||
|
||||
int BN_cmp(BIGNUM */*a*/, BIGNUM */*b*/);
|
||||
|
||||
BIGNUM *BN_bin2bn(const uint8_t */*buf*/, int /*size*/, BIGNUM */*bn*/);
|
||||
int BN_bn2bin(const BIGNUM */*a*/, unsigned char */*b*/);
|
||||
char *BN_bn2hex(const BIGNUM */*a*/);
|
||||
char *BN_bn2dec(const BIGNUM */*a*/);
|
||||
int BN_hex2bn(BIGNUM **/*a*/, const char */*str*/);
|
||||
int BN_dec2bn(BIGNUM **/*a*/, const char */*str*/);
|
||||
#ifndef _KERNEL
|
||||
int BN_print_fp(FILE */*fp*/, const BIGNUM */*a*/);
|
||||
#endif
|
||||
|
||||
int BN_add(BIGNUM */*r*/, const BIGNUM */*a*/, const BIGNUM */*b*/);
|
||||
int BN_sub(BIGNUM */*r*/, const BIGNUM */*a*/, const BIGNUM */*b*/);
|
||||
int BN_mul(BIGNUM */*r*/, const BIGNUM */*a*/, const BIGNUM */*b*/, BN_CTX */*ctx*/);
|
||||
int BN_div(BIGNUM */*q*/, BIGNUM */*r*/, const BIGNUM */*a*/, const BIGNUM */*b*/, BN_CTX */*ctx*/);
|
||||
void BN_swap(BIGNUM */*a*/, BIGNUM */*b*/);
|
||||
int BN_lshift(BIGNUM */*r*/, const BIGNUM */*a*/, int /*n*/);
|
||||
int BN_lshift1(BIGNUM */*r*/, BIGNUM */*a*/);
|
||||
int BN_rshift(BIGNUM */*r*/, const BIGNUM */*a*/, int /*n*/);
|
||||
int BN_rshift1(BIGNUM */*r*/, BIGNUM */*a*/);
|
||||
int BN_set_word(BIGNUM */*a*/, BN_ULONG /*w*/);
|
||||
void BN_set_negative(BIGNUM */*a*/, int /*n*/);
|
||||
|
||||
int BN_num_bytes(const BIGNUM */*a*/);
|
||||
int BN_num_bits(const BIGNUM */*a*/);
|
||||
|
||||
int BN_mod_exp(BIGNUM */*r*/, BIGNUM */*a*/, BIGNUM */*p*/, BIGNUM */*m*/, BN_CTX */*ctx*/);
|
||||
BIGNUM *BN_mod_inverse(BIGNUM */*ret*/, BIGNUM */*a*/, const BIGNUM */*n*/, BN_CTX */*ctx*/);
|
||||
int BN_mod_mul(BIGNUM */*ret*/, BIGNUM */*a*/, BIGNUM */*b*/, const BIGNUM */*m*/, BN_CTX */*ctx*/);
|
||||
int BN_mod_sub(BIGNUM */*r*/, BIGNUM */*a*/, BIGNUM */*b*/, const BIGNUM */*m*/, BN_CTX */*ctx*/);
|
||||
|
||||
BN_CTX *BN_CTX_new(void);
|
||||
BIGNUM *BN_CTX_get(BN_CTX */*ctx*/);
|
||||
void BN_CTX_start(BN_CTX */*ctx*/);
|
||||
void BN_CTX_end(BN_CTX */*ctx*/);
|
||||
void BN_CTX_init(BN_CTX */*c*/);
|
||||
void BN_CTX_free(BN_CTX */*c*/);
|
||||
|
||||
int BN_rand(BIGNUM */*rnd*/, int /*bits*/, int /*top*/, int /*bottom*/);
|
||||
int BN_rand_range(BIGNUM */*rnd*/, BIGNUM */*range*/);
|
||||
|
||||
int BN_is_prime(const BIGNUM */*a*/, int /*checks*/, void (*callback)(int, int, void *), BN_CTX */*ctx*/, void */*cb_arg*/);
|
||||
|
||||
const BIGNUM *BN_value_one(void);
|
||||
int BN_is_bit_set(const BIGNUM */*a*/, int /*n*/);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,304 @@
|
||||
.\" $NetBSD: libnetpgpbn.3,v 1.3 2013/07/20 21:39:56 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2010 Alistair Crooks <agc@NetBSD.org>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd April 13, 2012
|
||||
.Dt LIBNETPGPBN 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm libnetpgpbn
|
||||
.Nd BIGNUM library of multi-precision integers
|
||||
.Sh LIBRARY
|
||||
.Lb libnetpgpbn
|
||||
.Sh SYNOPSIS
|
||||
.In netpgp/bn.h
|
||||
.Ft BIGNUM *
|
||||
.Fo BN_new
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Ft BIGNUM *
|
||||
.Fo BN_dup
|
||||
.Fa "const BIGNUM *orig"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_copy
|
||||
.Fa "BIGNUM *to" "const BIGNUM *from"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_swap
|
||||
.Fa "BIGNUM *a" "BIGNUM *b"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo BN_init
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_free
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_clear
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_clear_free
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo BN_clear_free
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fo BN_cmp
|
||||
.Fa "BIGNUM *lhs" "BIGNUM *rhs"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_is_negative
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_is_zero
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_is_odd
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_is_even
|
||||
.Fa "BIGNUM *bn"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft BIGNUM *
|
||||
.Fo BN_bin2bn
|
||||
.Fa "const uint8_t *buf" "int size" "BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_bn2bin
|
||||
.Fa "BIGNUM *bn" "uint8_t *buf"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_bn2bin
|
||||
.Fa "BIGNUM *bn" "uint8_t *buf"
|
||||
.Fc
|
||||
.Ft char *
|
||||
.Fo BN_bn2hex
|
||||
.Fa "const BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft char *
|
||||
.Fo BN_bn2dec
|
||||
.Fa "const BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_hex2bn
|
||||
.Fa "BIGNUM **bn" "const char *str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_dec2bn
|
||||
.Fa "BIGNUM **bn" "const char *str"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_print_fp
|
||||
.Fa "FILE *fp" "const BIGNUM *bn"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fo BN_add
|
||||
.Fa "BIGNUM *sum" "const BIGNUM *a" "const BIGNUM *b"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_sub
|
||||
.Fa "BIGNUM *sum" "const BIGNUM *a" "const BIGNUM *b"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_mul
|
||||
.Fa "BIGNUM *product" "const BIGNUM *a" "const BIGNUM *b" "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_div
|
||||
.Fa "BIGNUM *quotient" "BIGNUM *remainder" "const BIGNUM *a" "const BIGNUM *b" "BN_CTX *context"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fo BN_lshift
|
||||
.Fa "BIGNUM *result" "const BIGNUM *bn" "int n"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_lshift1
|
||||
.Fa "BIGNUM *result" "const BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_rshift
|
||||
.Fa "BIGNUM *result" "const BIGNUM *bn" "int n"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_rshift1
|
||||
.Fa "BIGNUM *result" "const BIGNUM *bn"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fo BN_set_word
|
||||
.Fa "BIGNUM *result" "unsigned long val"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_set_negative
|
||||
.Fa "BIGNUM *result" "int val"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fo BN_num_bytes
|
||||
.Fa "const BIGNUM *bn"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_num_bits
|
||||
.Fa "const BIGNUM *bn"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft int
|
||||
.Fo BN_mod_exp
|
||||
.Fa "BIGNUM *result" "BIGNUM *a" "BIGNUM *p" "BIGNUM *m" "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft BIGNUM *
|
||||
.Fo BN_mod_inverse
|
||||
.Fa "BIGNUM *result" "BIGNUM *a" "BIGNUM *n" "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_mod_mul
|
||||
.Fa "BIGNUM *result" "BIGNUM *a" "BIGNUM *b" "BIGNUM *m" "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_mod_sub
|
||||
.Fa "BIGNUM *result" "BIGNUM *a" "BIGNUM *b" "BIGNUM *m" "BN_CTX *context"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft BN_CTX *
|
||||
.Fo BN_CTX_new
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Ft BIGNUM *
|
||||
.Fo BN_CTX_get
|
||||
.Fa "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_CTX_start
|
||||
.Fa "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_CTX_end
|
||||
.Fa "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_CTX_init
|
||||
.Fa "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo BN_CTX_free
|
||||
.Fa "BN_CTX *context"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_rand
|
||||
.Fa "BIGNUM *result" "int bits" "int top" "int bottom"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_rand_range
|
||||
.Fa "BIGNUM *result" "BIGNUM *range"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_is_prime
|
||||
.Fa "const BIGNUM *bn" "int checks" "void (*callback)(int int void)"
|
||||
.Fa "BN_CTX *context" "void *callbackarg"
|
||||
.Fc
|
||||
.Pp
|
||||
.Ft const BIGNUM *
|
||||
.Fo BN_value_one
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Ft int
|
||||
.Fo BN_is_bit_set
|
||||
.Fa "const BIGNUM *bn" "int n"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
emulates the API of the openssl
|
||||
.Xr bn 3
|
||||
library.
|
||||
It is implemented using Tom St Denis
|
||||
.Dq libtommath
|
||||
library.
|
||||
.Sh EXAMPLES
|
||||
The follow code fragment will make a JSON object
|
||||
out of the string
|
||||
.Dq Hello <USERNAME>\en
|
||||
in the
|
||||
buffer called
|
||||
.Dq buf
|
||||
where
|
||||
.Dq USERNAME
|
||||
is the name of the user taken from the runtime environment.
|
||||
The encoded text will be in an allocated buffer called
|
||||
.Dq s
|
||||
.Bd -literal -offset indent
|
||||
mj_t atom;
|
||||
char buf[BUFSIZ];
|
||||
char *s;
|
||||
int cc;
|
||||
|
||||
(void) memset(\*[Am]atom, 0x0, sizeof(atom));
|
||||
cc = snprintf(buf, sizeof(buf), "Hello %s\en", getenv("USER"));
|
||||
mj_create(\*[Am]atom, "string", buf, cc);
|
||||
cc = mj_asprint(\*[Am]s, \*[Am]atom, MJ_JSON_ENCODE);
|
||||
.Ed
|
||||
.Pp
|
||||
and the following example will take the (binary) text which has been encoded into
|
||||
JSON and is in the buffer
|
||||
.Dq buf ,
|
||||
such as in the previous example, and re-create the original text:
|
||||
.Bd -literal -offset indent
|
||||
int from, to, tok, cc;
|
||||
char *s;
|
||||
mj_t atom;
|
||||
|
||||
(void) memset(\*[Am]atom, 0x0, sizeof(atom));
|
||||
from = to = tok = 0;
|
||||
mj_parse(\*[Am]atom, buf, \*[Am]from, \*[Am]to, \*[Am]tok);
|
||||
cc = mj_asprint(\*[Am]s, \*[Am]atom, MJ_HUMAN);
|
||||
printf("%.*s", cc, s);
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Dv s
|
||||
pointer points to allocated storage with the original NUL-terminated string
|
||||
in it.
|
||||
.Sh SEE ALSO
|
||||
.Xr bn 3
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
library first appeared in
|
||||
.Nx 7.0 .
|
||||
.Sh AUTHORS
|
||||
.An Alistair Crooks Aq Mt agc@NetBSD.org
|
||||
@@ -0,0 +1,82 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
# include <sys/kmem.h>
|
||||
#else
|
||||
# include <ctype.h>
|
||||
# include <inttypes.h>
|
||||
# include <stdarg.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <time.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
#ifndef USE_ARG
|
||||
#define USE_ARG(x) /*LINTED*/(void)&(x)
|
||||
#endif
|
||||
|
||||
void *
|
||||
netpgp_allocate(size_t n, size_t nels)
|
||||
{
|
||||
#ifdef _KERNEL
|
||||
return kmem_zalloc(n * nels, KM_SLEEP);
|
||||
#else
|
||||
return calloc(n, nels);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
netpgp_deallocate(void *ptr, size_t size)
|
||||
{
|
||||
#ifdef _KERNEL
|
||||
kmem_free(ptr, size);
|
||||
#else
|
||||
USE_ARG(size);
|
||||
free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _KERNEL
|
||||
void
|
||||
logmessage(const int level, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
USE_ARG(level);
|
||||
if (fmt != NULL) {
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef MISC_H_
|
||||
#define MISC_H_ 20110705
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifndef __BEGIN_DECLS
|
||||
# if defined(__cplusplus)
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
# else
|
||||
# define __BEGIN_DECLS
|
||||
# define __END_DECLS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
void *netpgp_allocate(size_t /*n*/, size_t /*nels*/);
|
||||
void netpgp_deallocate(void */*ptr*/, size_t /*size*/);
|
||||
|
||||
#ifndef _KERNEL
|
||||
void logmessage(const int /*level*/, const char */*fmt*/, ...);
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
# include <sys/kmem.h>
|
||||
#else
|
||||
# include <arpa/inet.h>
|
||||
# include <ctype.h>
|
||||
# include <inttypes.h>
|
||||
# include <stdarg.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <time.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "rand.h"
|
||||
|
||||
int
|
||||
RAND_bytes(unsigned char *buf, int num)
|
||||
{
|
||||
uint32_t r;
|
||||
size_t cc;
|
||||
int i;
|
||||
|
||||
if (buf == NULL || num < 0) {
|
||||
return 0;
|
||||
}
|
||||
for (i = 0 ; i < num ; i += sizeof(r)) {
|
||||
r = arc4random();
|
||||
cc = MIN(sizeof(r), (size_t)(num - i));
|
||||
(void) memcpy(&buf[i], &r, cc);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef RAND_H_
|
||||
#define RAND_H_ 20120327
|
||||
|
||||
#ifndef __BEGIN_DECLS
|
||||
# if defined(__cplusplus)
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
# else
|
||||
# define __BEGIN_DECLS
|
||||
# define __END_DECLS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int RAND_bytes(unsigned char */*buf*/, int /*len*/);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
# include <sys/kmem.h>
|
||||
#else
|
||||
# include <arpa/inet.h>
|
||||
# include <ctype.h>
|
||||
# include <inttypes.h>
|
||||
# include <stdarg.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <time.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "misc.h"
|
||||
#include "bn.h"
|
||||
|
||||
#include "stubs.h"
|
||||
|
||||
#ifndef USE_ARG
|
||||
#define USE_ARG(x) /*LINTED*/(void)&(x)
|
||||
#endif
|
||||
|
||||
void
|
||||
OpenSSL_add_all_algorithms(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
OPENSSL_add_all_algorithms_noconf(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CRYPTO_cleanup_all_ex_data(void)
|
||||
{
|
||||
}
|
||||
|
||||
BIO *
|
||||
BIO_new_fd(int fd, int close_flag)
|
||||
{
|
||||
USE_ARG(fd);
|
||||
USE_ARG(close_flag);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned long
|
||||
ERR_get_error(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
ERR_error_string(unsigned long e, char *buf)
|
||||
{
|
||||
static char staticbuf[120];
|
||||
|
||||
if (buf == NULL) {
|
||||
buf = staticbuf;
|
||||
}
|
||||
snprintf(buf, 120, "error:%lu:netssl:[unknown function]:[unknown error]", e);
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
ERR_remove_state(unsigned long pid)
|
||||
{
|
||||
USE_ARG(pid);
|
||||
}
|
||||
|
||||
void
|
||||
ERR_print_errors(BIO *bp)
|
||||
{
|
||||
USE_ARG(bp);
|
||||
}
|
||||
|
||||
void
|
||||
idea_set_encrypt_key(uint8_t *key, IDEA_KEY_SCHEDULE *ks)
|
||||
{
|
||||
printf("idea_set_encrypt_key stubbed\n");
|
||||
USE_ARG(key);
|
||||
USE_ARG(ks);
|
||||
}
|
||||
|
||||
void
|
||||
idea_set_decrypt_key(IDEA_KEY_SCHEDULE *encrypt_ks, IDEA_KEY_SCHEDULE *decrypt_ks)
|
||||
{
|
||||
printf("idea_set_decrypt_key stubbed\n");
|
||||
USE_ARG(encrypt_ks);
|
||||
USE_ARG(decrypt_ks);
|
||||
}
|
||||
|
||||
void
|
||||
idea_cfb64_encrypt(uint8_t *in, uint8_t *out, long length, des_key_schedule *ks, des_cblock *ivec, int *num, int enc)
|
||||
{
|
||||
printf("idea_cfb64_encrypt stubbed\n");
|
||||
USE_ARG(in);
|
||||
USE_ARG(out);
|
||||
USE_ARG(length);
|
||||
USE_ARG(ks);
|
||||
USE_ARG(ivec);
|
||||
USE_ARG(num);
|
||||
USE_ARG(enc);
|
||||
}
|
||||
|
||||
void
|
||||
idea_ecb_encrypt(uint8_t *in, uint8_t *out, IDEA_KEY_SCHEDULE *ks)
|
||||
{
|
||||
printf("idea_cfb64_decrypt stubbed\n");
|
||||
USE_ARG(in);
|
||||
USE_ARG(out);
|
||||
USE_ARG(ks);
|
||||
}
|
||||
|
||||
int
|
||||
Camellia_set_key(const unsigned char *userKey, const int bits, CAMELLIA_KEY *key)
|
||||
{
|
||||
printf("Camellia_set_key stubbed\n");
|
||||
USE_ARG(userKey);
|
||||
USE_ARG(bits);
|
||||
USE_ARG(key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Camellia_encrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key)
|
||||
{
|
||||
printf("Camellia_encrypt stubbed\n");
|
||||
USE_ARG(in);
|
||||
USE_ARG(out);
|
||||
USE_ARG(key);
|
||||
}
|
||||
|
||||
void
|
||||
Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, const CAMELLIA_KEY *key, unsigned char *ivec, int *num, const int enc)
|
||||
{
|
||||
printf("Camellia_cfb128_encrypt stubbed\n");
|
||||
USE_ARG(in);
|
||||
USE_ARG(out);
|
||||
USE_ARG(length);
|
||||
USE_ARG(key);
|
||||
USE_ARG(ivec);
|
||||
USE_ARG(num);
|
||||
USE_ARG(enc);
|
||||
}
|
||||
|
||||
void
|
||||
Camellia_decrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key)
|
||||
{
|
||||
printf("Camellia_decrypt stubbed\n");
|
||||
USE_ARG(in);
|
||||
USE_ARG(out);
|
||||
USE_ARG(key);
|
||||
}
|
||||
|
||||
int
|
||||
DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule)
|
||||
{
|
||||
printf("DES_set_key stubbed\n");
|
||||
USE_ARG(key);
|
||||
USE_ARG(schedule);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks1,DES_key_schedule *ks2, DES_key_schedule *ks3, int enc)
|
||||
{
|
||||
printf("DES_ecb3_encrypt stubbed\n");
|
||||
USE_ARG(input);
|
||||
USE_ARG(output);
|
||||
USE_ARG(ks1);
|
||||
USE_ARG(ks2);
|
||||
USE_ARG(ks3);
|
||||
USE_ARG(enc);
|
||||
}
|
||||
|
||||
void
|
||||
DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, long length,DES_key_schedule *ks1, DES_key_schedule *ks2,DES_key_schedule *ks3, DES_cblock *ivec,int *num,int enc)
|
||||
{
|
||||
printf("DES_ede3_cfb64_encrypt stubbed\n");
|
||||
USE_ARG(in);
|
||||
USE_ARG(out);
|
||||
USE_ARG(length);
|
||||
USE_ARG(ks1);
|
||||
USE_ARG(ks2);
|
||||
USE_ARG(ks3);
|
||||
USE_ARG(ivec);
|
||||
USE_ARG(num);
|
||||
USE_ARG(enc);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/*-
|
||||
* Copyright (c) 2012 Alistair Crooks <agc@NetBSD.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef STUBS_H_
|
||||
#define STUBS_H_ 20120327
|
||||
|
||||
#ifndef __BEGIN_DECLS
|
||||
# if defined(__cplusplus)
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
# else
|
||||
# define __BEGIN_DECLS
|
||||
# define __END_DECLS
|
||||
# endif
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
/*********************************/
|
||||
/* stubs */
|
||||
/*********************************/
|
||||
|
||||
void OpenSSL_add_all_algorithms(void);
|
||||
void OPENSSL_add_all_algorithms_noconf(void);
|
||||
void CRYPTO_cleanup_all_ex_data(void);
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define BIO FILE
|
||||
|
||||
BIO *BIO_new_fd(int /*fd*/, int /*close_flag*/);
|
||||
|
||||
unsigned long ERR_get_error(void);
|
||||
char *ERR_error_string(unsigned long /*e*/, char */*buf*/);
|
||||
void ERR_remove_state(unsigned long /*pid*/);
|
||||
void ERR_print_errors(BIO */*bp*/);
|
||||
|
||||
#define IDEA_KEY_SCHEDULE void
|
||||
#define des_key_schedule void
|
||||
#define des_cblock void
|
||||
#define IDEA_DECRYPT 0
|
||||
#define IDEA_ENCRYPT 1
|
||||
#define IDEA_BLOCK 8
|
||||
#define IDEA_KEY_LENGTH 16
|
||||
|
||||
void idea_set_encrypt_key(uint8_t *key, IDEA_KEY_SCHEDULE *ks);
|
||||
void idea_set_decrypt_key(IDEA_KEY_SCHEDULE *encrypt_ks, IDEA_KEY_SCHEDULE *decrypt_ks);
|
||||
void idea_cfb64_encrypt(uint8_t *in, uint8_t *out, long length, des_key_schedule *ks, des_cblock *ivec, int *num, int enc);
|
||||
void idea_ecb_encrypt(uint8_t *in, uint8_t *out, IDEA_KEY_SCHEDULE *ks);
|
||||
|
||||
#define CAMELLIA_KEY void
|
||||
#define CAMELLIA_DECRYPT 0
|
||||
#define CAMELLIA_ENCRYPT 1
|
||||
#define CAMELLIA_BLOCK_SIZE 16
|
||||
|
||||
int Camellia_set_key(const unsigned char *userKey, const int bits, CAMELLIA_KEY *key);
|
||||
void Camellia_encrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key);
|
||||
void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, size_t length, const CAMELLIA_KEY *key, unsigned char *ivec, int *num, const int enc);
|
||||
void Camellia_decrypt(const unsigned char *in, unsigned char *out, const CAMELLIA_KEY *key);
|
||||
|
||||
#define const_DES_cblock void
|
||||
#define DES_cblock void
|
||||
#define DES_key_schedule void
|
||||
#define DES_DECRYPT 0
|
||||
#define DES_ENCRYPT 1
|
||||
|
||||
int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
|
||||
void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, DES_key_schedule *ks1,DES_key_schedule *ks2, DES_key_schedule *ks3, int enc);
|
||||
void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, long length,DES_key_schedule *ks1, DES_key_schedule *ks2,DES_key_schedule *ks3, DES_cblock *ivec,int *num,int enc);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user