Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

com.sleepycat.db.Database.verify(), not working with encrypted db. bug?

999385Mar 26 2013 — edited Apr 17 2013
Hi,

I have a berkeley database file encrypted with a password (In fact, there are two databases embedded in the same physical file). The Berkeley api version that I'm using is the 5.3.21:

The databases work fine, and I can read all the encrypted data (in both databases)...

However, if I try to verifiy the database with the method, com.sleepycat.db.Database.verify(), I get the following error...

BDB0196 Encrypted checksum: no encryption key specified
BDB0522 Page 0: metadata page corrupted
BDB0196 Encrypted checksum: no encryption key specified
BDB3016 C:\cneDir\env-cipher/inforep.db: pgin failed for page 0

Even if setup the databaseConfig object with my password... This is the code that I'm using:
    private static void doVerify(String args[], String symmetricKey) {
        DatabaseConfig dbConfig;
        VerifyConfig verifyConfig;
        String filename;
        String dbName;
        boolean result;

        filename = args[0] + "/" + args[1];
        dbName   = args[2];

        dbConfig = new DatabaseConfig();
        dbConfig.setEncrypted(symmetricKey);
        System.out.println("Is encrypted: " + dbConfig.getEncrypted());
        dbConfig.setChecksum(true);

        verifyConfig = new VerifyConfig();
        verifyConfig.setNoOrderCheck(false);

        try {
            result = Database.verify(filename, dbName, System.out, verifyConfig, dbConfig);
            System.out.println("Everything is OK? " + result);
        } catch (Exception ex) {
            System.out.println("D OH!");
            ex.printStackTrace();
        }
This forced me to take the source code of the Java API to see what is happening...
Atfer looking the API source code, it seems to me that the method com.sleepycat.db.Database.verify(), never sets the password at any point of its execution... So, I take the source code and I modify the method to set my password (Hardcoded):
    public static boolean verify(final String fileName,
                                 final String databaseName,
                                 final java.io.PrintStream dumpStream,
                                 VerifyConfig verifyConfig,
                                 DatabaseConfig dbConfig)
        throws DatabaseException, java.io.FileNotFoundException {

        final Db db = DatabaseConfig.checkNull(dbConfig).createDatabase(null);
        //db.set_flags(DbConstants.DB_ENCRYPT);
        db.set_encrypt("1234", DbConstants.DB_ENCRYPT_AES);   //Here, 1234 is my password
        return db.verify(fileName, databaseName, dumpStream,
                         VerifyConfig.checkNull(verifyConfig).getFlags());
    }
Atfer this modification, the method com.sleepycat.db.Database.verify() returns true and doesn't throw any exception. So, I'm guessing that this could be a bug, right??
This post has been answered by JinZhao-Oracle on Apr 17 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 15 2013
Added on Mar 26 2013
1 comment
511 views