diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2007-07-30 11:58:31 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2007-07-30 11:58:31 +0300 |
commit | cab228435bde1b5496522c03a4ce9840f2ef3701 (patch) | |
tree | 2c37b65d176e2de097603333f4de071c31eeff3d /db/crypto | |
parent | 2d07882d45e9e575c00f8f402d4c7271bb65cfe9 (diff) | |
download | librpm-tizen-cab228435bde1b5496522c03a4ce9840f2ef3701.tar.gz librpm-tizen-cab228435bde1b5496522c03a4ce9840f2ef3701.tar.bz2 librpm-tizen-cab228435bde1b5496522c03a4ce9840f2ef3701.zip |
Update internal BDB to version 4.6.18.
Diffstat (limited to 'db/crypto')
-rw-r--r-- | db/crypto/aes_method.c | 5 | ||||
-rw-r--r-- | db/crypto/crypto.c | 66 | ||||
-rw-r--r-- | db/crypto/crypto.html | 2 | ||||
-rw-r--r-- | db/crypto/mersenne/mt19937db.c | 13 |
4 files changed, 46 insertions, 40 deletions
diff --git a/db/crypto/aes_method.c b/db/crypto/aes_method.c index cd4370b3a..bc0d191ff 100644 --- a/db/crypto/aes_method.c +++ b/db/crypto/aes_method.c @@ -1,13 +1,12 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2001-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 2001,2007 Oracle. All rights reserved. * * Some parts of this code originally written by Adam Stubblefield, * -- astubble@rice.edu. * - * $Id: aes_method.c,v 12.5 2006/08/24 14:45:12 bostic Exp $ + * $Id: aes_method.c,v 12.7 2007/05/17 15:14:55 bostic Exp $ */ #include "db_config.h" diff --git a/db/crypto/crypto.c b/db/crypto/crypto.c index 72a8444e0..d39f60c7c 100644 --- a/db/crypto/crypto.c +++ b/db/crypto/crypto.c @@ -1,13 +1,12 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1996,2007 Oracle. All rights reserved. * * Some parts of this code originally written by Adam Stubblefield * -- astubble@rice.edu * - * $Id: crypto.c,v 12.10 2006/08/24 14:45:12 bostic Exp $ + * $Id: crypto.c,v 12.20 2007/05/17 15:14:55 bostic Exp $ */ #include "db_config.h" @@ -53,13 +52,12 @@ __crypto_region_init(dbenv) * information that contains the passwd. After we copy the * passwd, we smash and free the one in the dbenv. */ - if ((ret = - __db_shalloc(infop, sizeof(CIPHER), 0, &cipher)) != 0) + if ((ret = __env_alloc(infop, sizeof(CIPHER), &cipher)) != 0) return (ret); memset(cipher, 0, sizeof(*cipher)); - if ((ret = __db_shalloc( - infop, dbenv->passwd_len, 0, &sh_passwd)) != 0) { - __db_shalloc_free(infop, cipher); + if ((ret = + __env_alloc(infop, dbenv->passwd_len, &sh_passwd)) != 0) { + __env_alloc_free(infop, cipher); return (ret); } memset(sh_passwd, 0, dbenv->passwd_len); @@ -113,53 +111,64 @@ __crypto_region_init(dbenv) } /* - * __crypto_dbenv_close -- + * __crypto_env_close -- * Crypto-specific destruction of DB_ENV structure. * - * PUBLIC: int __crypto_dbenv_close __P((DB_ENV *)); + * PUBLIC: int __crypto_env_close __P((DB_ENV *)); */ int -__crypto_dbenv_close(dbenv) +__crypto_env_close(dbenv) DB_ENV *dbenv; { DB_CIPHER *db_cipher; int ret; - ret = 0; - db_cipher = dbenv->crypto_handle; if (dbenv->passwd != NULL) { memset(dbenv->passwd, 0xff, dbenv->passwd_len-1); __os_free(dbenv, dbenv->passwd); dbenv->passwd = NULL; } + if (!CRYPTO_ON(dbenv)) return (0); + + ret = 0; + db_cipher = dbenv->crypto_handle; if (!F_ISSET(db_cipher, CIPHER_ANY)) ret = db_cipher->close(dbenv, db_cipher->data); __os_free(dbenv, db_cipher); + + dbenv->crypto_handle = NULL; return (ret); } /* - * __crypto_region_destroy -- - * Destroy any system resources allocated in the primary region. + * __crypto_env_refresh -- + * Clean up after the crpto system on a close or failed open. * - * PUBLIC: int __crypto_region_destroy __P((DB_ENV *)); + * PUBLIC: int __crypto_env_refresh __P((DB_ENV *)); */ int -__crypto_region_destroy(dbenv) +__crypto_env_refresh(dbenv) DB_ENV *dbenv; { CIPHER *cipher; REGENV *renv; REGINFO *infop; - infop = dbenv->reginfo; - renv = infop->primary; - if (renv->cipher_off != INVALID_ROFF) { - cipher = R_ADDR(infop, renv->cipher_off); - __db_shalloc_free(infop, R_ADDR(infop, cipher->passwd)); - __db_shalloc_free(infop, cipher); + /* + * If a private region, return the memory to the heap. Not needed for + * filesystem-backed or system shared memory regions, that memory isn't + * owned by any particular process. + */ + if (F_ISSET(dbenv, DB_ENV_PRIVATE)) { + infop = dbenv->reginfo; + renv = infop->primary; + if (renv->cipher_off != INVALID_ROFF) { + cipher = R_ADDR(infop, renv->cipher_off); + __env_alloc_free(infop, R_ADDR(infop, cipher->passwd)); + __env_alloc_free(infop, cipher); + } } return (0); } @@ -192,10 +201,10 @@ __crypto_algsetup(dbenv, db_cipher, alg, do_init) ret = __aes_setup(dbenv, db_cipher); break; default: - __db_panic(dbenv, EINVAL); - /* NOTREACHED */ + ret = __db_panic(dbenv, EINVAL); + break; } - if (do_init) + if (ret == 0 && do_init) ret = db_cipher->init(dbenv, db_cipher); return (ret); } @@ -248,8 +257,7 @@ __crypto_decrypt_meta(dbenv, dbp, mbuf, do_metachk) * since been removed). * * Ugly check to jump out if this format is older than what we support. - * It assumes no encrypted page will have an unencrypted magic number, - * but that seems relatively safe. [#10920] + * This works because we do not encrypt the page header. */ if (meta->magic == DB_HASHMAGIC && meta->version <= 5) return (0); @@ -376,9 +384,7 @@ __crypto_set_passwd(dbenv_src, dbenv_dest) REGENV *renv; REGINFO *infop; char *sh_passwd; - int ret; - ret = 0; infop = dbenv_src->reginfo; renv = infop->primary; diff --git a/db/crypto/crypto.html b/db/crypto/crypto.html index 129a7f4f3..1a2dc0c15 100644 --- a/db/crypto/crypto.html +++ b/db/crypto/crypto.html @@ -413,7 +413,7 @@ in the log buffer. Records in that buffer will be encrypted, so decryption will occur no matter whether we are returning records from the buffer or if we are returning log records directly from the disk. Current checksum checking is done in -<i>__log_get_c_int.</i> Decryption will be done +<i>__logc_get_int.</i> Decryption will be done after the checksum is checked. <p>There are currently two nasty issues with encrypted log records. The first is that <i>__txn_force_abort</i> overwrites a commit record in diff --git a/db/crypto/mersenne/mt19937db.c b/db/crypto/mersenne/mt19937db.c index 6cd259932..aa20928a2 100644 --- a/db/crypto/mersenne/mt19937db.c +++ b/db/crypto/mersenne/mt19937db.c @@ -1,5 +1,5 @@ /* - * $Id: mt19937db.c,v 12.4 2006/09/08 20:32:02 bostic Exp $ + * $Id: mt19937db.c,v 12.6 2007/04/18 18:16:04 bostic Exp $ */ #include "db_config.h" @@ -138,10 +138,11 @@ static unsigned long __db_genrand(dbenv) DB_ENV *dbenv; { + db_timespec ts; unsigned long y; static unsigned long mag01[2]={0x0, MATRIX_A}; /* mag01[x] = x * MATRIX_A for x=0,1 */ - u_int32_t secs, seed, usecs; + u_int32_t seed; /* * We are called with DB_ENV->mtx_mt locked. @@ -155,11 +156,11 @@ __db_genrand(dbenv) * function will return 4 bytes if we don't send in a key. */ do { - __os_clock(dbenv, &secs, &usecs); - __db_chksum(NULL, (u_int8_t *)&secs, sizeof(secs), NULL, - (u_int8_t *)&seed); + __os_gettime(dbenv, &ts); + __db_chksum(NULL, (u_int8_t *)&ts.tv_sec, + sizeof(ts.tv_sec), NULL, (u_int8_t *)&seed); } while (seed == 0); - __db_sgenrand((long)seed, dbenv->mt, &dbenv->mti); + __db_sgenrand((unsigned long)seed, dbenv->mt, &dbenv->mti); } for (kk=0;kk<N-M;kk++) { |