Mercurial > hg > openjdk > jigsaw > bdb
view src/dbinc/crypto.h @ 0:a1985f14b030
Initial load
author | chegar |
---|---|
date | Fri, 11 May 2012 10:42:02 +0100 |
parents | |
children |
line wrap: on
line source
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved. * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * * $Id$ */ #ifndef _DB_CRYPTO_H_ #define _DB_CRYPTO_H_ #if defined(__cplusplus) extern "C" { #endif #ifdef HAVE_CRYPTO_IPP #include <ippcp.h> #endif /* * !!! * These are the internal representations of the algorithm flags. * They are used in both the DB_CIPHER structure and the CIPHER * structure so we can tell if users specified both passwd and alg * correctly. * * CIPHER_ANY is used when an app joins an existing env but doesn't * know the algorithm originally used. This is only valid in the * DB_CIPHER structure until we open and can set the alg. */ /* * We store the algorithm in an 8-bit field on the meta-page. So we * use a numeric value, not bit fields. * now we are limited to 8 algorithms before we cannot use bits and * need numeric values. That should be plenty. It is okay for the * CIPHER_ANY flag to go beyond that since that is never stored on disk. */ /* * This structure is per-process, not in shared memory. */ struct __db_cipher { u_int (*adj_size) __P((size_t)); int (*close) __P((ENV *, void *)); int (*decrypt) __P((ENV *, void *, void *, u_int8_t *, size_t)); int (*encrypt) __P((ENV *, void *, void *, u_int8_t *, size_t)); int (*init) __P((ENV *, DB_CIPHER *)); u_int8_t mac_key[DB_MAC_KEY]; /* MAC key. */ void *data; /* Algorithm-specific information */ #define CIPHER_AES 1 /* AES algorithm */ u_int8_t alg; /* Algorithm used - See above */ u_int8_t spare[3]; /* Spares */ #define CIPHER_ANY 0x00000001 /* Only for DB_CIPHER */ u_int32_t flags; /* Other flags */ }; #ifdef HAVE_CRYPTO #include "crypto/rijndael/rijndael-api-fst.h" /* * Shared ciphering structure * No mutex needed because all information is read-only after creation. */ typedef struct __cipher { roff_t passwd; /* Offset to shared passwd */ size_t passwd_len; /* Length of passwd */ u_int32_t flags; /* Algorithm used - see above */ } CIPHER; #define DB_AES_KEYLEN 128 /* AES key length */ #define DB_AES_CHUNK 16 /* AES byte unit size */ typedef struct __aes_cipher { #ifdef HAVE_CRYPTO_IPP void *ipp_ctx; /* IPP key instance */ #else keyInstance decrypt_ki; /* Decryption key instance */ keyInstance encrypt_ki; /* Encryption key instance */ #endif u_int32_t flags; /* AES-specific flags */ } AES_CIPHER; #include "dbinc_auto/crypto_ext.h" #endif /* HAVE_CRYPTO */ #if defined(__cplusplus) } #endif #endif /* !_DB_CRYPTO_H_ */