rv = (SECStatus)(* handle->updatedb->get)(handle->updatedb, &checkKey,
ret = (* handle->updatedb->get)(handle->updatedb, &checkKey,
SECKEY_UpdateKeyDBPass1(SECKEYKeyDBHandle *handle){    SECStatus rv;    DBT versionKey;    DBT versionData;    DBT checkKey;    DBT checkData;    DBT saltKey;    DBT saltData;    DBT key;    DBT data;    SECItem *rc4key = NULL;    SECKEYDBKey *dbkey = NULL;    SECItem *oldSalt = NULL;    int ret;    SECItem checkitem;    if ( handle->updatedb == NULL ) {	return(SECSuccess);    }    /*     * check the version record     */    versionKey.data = VERSION_STRING;    versionKey.size = sizeof(VERSION_STRING)-1;    ret = (* handle->updatedb->get)(handle->updatedb, &versionKey,				    &versionData, 0 );    if (ret) {	/* no version record, so old db never used */	goto done;    }    if ( ( versionData.size != 1 ) ||	( *((unsigned char *)versionData.data) != 2 ) ) {	/* corrupt or wrong version number so don't update */	goto done;    }    saltKey.data = SALT_STRING;    saltKey.size = sizeof(SALT_STRING) - 1;    ret = (* handle->updatedb->get)(handle->updatedb, &saltKey, &saltData, 0);    if ( ret ) {	/* no salt in old db, so it is corrupted */	goto done;    }    oldSalt = decodeKeyDBGlobalSalt(&saltData);    if ( oldSalt == NULL ) {	/* bad salt in old db, so it is corrupted */	goto done;    }    /*     * look for a pw check entry     */    checkKey.data = KEYDB_PW_CHECK_STRING;    checkKey.size = KEYDB_PW_CHECK_LEN;        rv = (SECStatus)(* handle->updatedb->get)(handle->updatedb, &checkKey,				   &checkData, 0 );    if (rv) {	/* no pw check, so old db never used */	goto done;    }    dbkey = decode_dbkey(&checkData, 2);    if ( dbkey == NULL ) {	goto done;    }        /* put global salt into the new database now */    ret = (* handle->db->put)( handle->db, &saltKey, &saltData, 0);    if ( ret ) {	goto done;    }    checkitem = dbkey->derPK;    dbkey->derPK.data = NULL;        /* format the new pw check entry */    rv = encodePWCheckEntry(NULL, &dbkey->derPK, SEC_OID_RC4, &checkitem);    if ( rv != SECSuccess ) {	goto done;    }    rv = put_dbkey(handle, &checkKey, dbkey, PR_TRUE);    if ( rv != SECSuccess ) {	goto done;    }    /* free the dbkey */    sec_destroy_dbkey(dbkey);    dbkey = NULL;        /* now traverse the database */    ret = (* handle->updatedb->seq)(handle->updatedb, &key, &data, R_FIRST);    if ( ret ) {	goto done;    }        do {	/* skip version record */	if ( data.size > 1 ) {	    /* skip salt */	    if ( key.size == ( sizeof(SALT_STRING) - 1 ) ) {		if ( PORT_Memcmp(key.data, SALT_STRING, key.size) == 0 ) {		    continue;		}	    }	    /* skip pw check entry */	    if ( key.size == checkKey.size ) {		if ( PORT_Memcmp(key.data, checkKey.data, key.size) == 0 ) {		    continue;		}	    }	    /* keys stored by nickname will have 0 as the last byte of the	     * db key.  Other keys must be stored by modulus.  We will not	     * update those because they are left over from a keygen that	     * never resulted in a cert.	     */	    if ( ((unsigned char *)key.data)[key.size-1] != 0 ) {		continue;	    }	    	    dbkey = decode_dbkey(&data, 2);	    if ( dbkey == NULL ) {		continue;	    }	    /* This puts the key into the new database with the same	     * index (nickname) that it had before.  The second pass	     * of the update will have the password.  It will decrypt	     * and re-encrypt the entries using a new algorithm.	     */	    dbkey->nickname = (char *)key.data;	    rv = put_dbkey(handle, &key, dbkey, PR_FALSE);	    dbkey->nickname = NULL;	    sec_destroy_dbkey(dbkey);	}    } while ( (* handle->updatedb->seq)(handle->updatedb, &key, &data,					R_NEXT) == 0 );    dbkey = NULL;done:    /* sync the database */    ret = (* handle->db->sync)(handle->db, 0);    (* handle->updatedb->close)(handle->updatedb);    handle->updatedb = NULL;        if ( rc4key ) {	SECITEM_FreeItem(rc4key, PR_TRUE);    }        if ( oldSalt ) {	SECITEM_FreeItem(oldSalt, PR_TRUE);    }        if ( dbkey ) {	sec_destroy_dbkey(dbkey);    }    return(SECSuccess);}