Examples of CipherProvider


Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      muckLength = AES_IV_LENGTH;   

    byte[] muck = getMuckFromBootPassword(bootPassword, muckLength);
    SecretKey key = generateKey(muck);
    byte[] IV = generateIV(muck);
                CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,key,IV);
   
    // store the actual secretKey.length before any possible padding 
    encodedKeyLength = secretKey.length;

    // for the secretKey to be encrypted, first ensure that it is aligned to the block size of the
    // encryption algorithm by padding bytes appropriately if needed
                secretKey = padKey(secretKey,tmpCipherProvider.getEncryptionBlockSize());

                byte[] result = new byte[secretKey.length];

    // encrypt the secretKey using the key generated of muck from  boot password and the generated IV 
    tmpCipherProvider.encrypt(secretKey, 0, secretKey.length, result, 0);

    return org.apache.derby.iapi.util.StringUtil.toHexString(result, 0, result.length);

  }
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      {
        getSecureRandom().nextBytes(data);
        // get the checksum
        byte[] checksum = getMD5Checksum(data);

        CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,mainSecretKey,mainIV);
        tmpCipherProvider.encrypt(data, 0, data.length, data, 0);
        // openFileForWrite
        verifyKeyFile = privAccessFile(sf,Attribute.CRYPTO_EXTERNAL_KEY_VERIFY_FILE,"rw");
        // write the checksum length as int, and then the checksum and then the encrypted data
        verifyKeyFile.writeInt(checksum.length);
        verifyKeyFile.write(checksum);
        verifyKeyFile.write(data);
        verifyKeyFile.sync(true);
      }
      else
      {
        // Read from verifyKey.dat as an InputStream. This allows for
                // reading the information from verifyKey.dat successfully even when using the jar
                // subprotocol to boot derby. (DERBY-1373)
        verifyKeyInputStream = privAccessGetInputStream(sf,Attribute.CRYPTO_EXTERNAL_KEY_VERIFY_FILE);
                DataInputStream dis = new DataInputStream(verifyKeyInputStream);
        // then read the checksum length
        int checksumLen = dis.readInt();

        byte[] originalChecksum = new byte[checksumLen];
        dis.readFully(originalChecksum);

        dis.readFully(data);

        // decrypt data with key
        CipherProvider tmpCipherProvider = createNewCipher(DECRYPT,mainSecretKey,mainIV);
        tmpCipherProvider.decrypt(data, 0, data.length, data, 0);

        byte[] verifyChecksum = getMD5Checksum(data);

        if(!MessageDigest.isEqual(originalChecksum,verifyChecksum))
        {
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      muckLength = AES_IV_LENGTH;   

    byte[] muck = getMuckFromBootPassword(bootPassword, muckLength);
    SecretKey key = generateKey(muck);
    byte[] IV = generateIV(muck);
                CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,key,IV);
   
    // store the actual secretKey.length before any possible padding 
    encodedKeyLength = secretKey.length;

    // for the secretKey to be encrypted, first ensure that it is aligned to the block size of the
    // encryption algorithm by padding bytes appropriately if needed
                secretKey = padKey(secretKey,tmpCipherProvider.getEncryptionBlockSize());

                byte[] result = new byte[secretKey.length];

    // encrypt the secretKey using the key generated of muck from  boot password and the generated IV 
    tmpCipherProvider.encrypt(secretKey, 0, secretKey.length, result, 0);

    return org.apache.derby.iapi.util.StringUtil.toHexString(result, 0, result.length);

  }
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      {
        getSecureRandom().nextBytes(data);
        // get the checksum
        byte[] checksum = getMD5Checksum(data);

        CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,mainSecretKey,mainIV);
        tmpCipherProvider.encrypt(data, 0, data.length, data, 0);
        // openFileForWrite
        verifyKeyFile = privAccessFile(sf,Attribute.CRYPTO_EXTERNAL_KEY_VERIFY_FILE,"rw");
        // write the checksum length as int, and then the checksum and then the encrypted data
        verifyKeyFile.writeInt(checksum.length);
        verifyKeyFile.write(checksum);
        verifyKeyFile.write(data);
        verifyKeyFile.sync(true);
      }
      else
      {
        // Read from verifyKey.dat as an InputStream. This allows for
                // reading the information from verifyKey.dat successfully even when using the jar
                // subprotocol to boot derby. (DERBY-1373)
        verifyKeyInputStream = privAccessGetInputStream(sf,Attribute.CRYPTO_EXTERNAL_KEY_VERIFY_FILE);
                DataInputStream dis = new DataInputStream(verifyKeyInputStream);
        // then read the checksum length
        int checksumLen = dis.readInt();

        byte[] originalChecksum = new byte[checksumLen];
        dis.readFully(originalChecksum);

        dis.readFully(data);

        // decrypt data with key
        CipherProvider tmpCipherProvider = createNewCipher(DECRYPT,mainSecretKey,mainIV);
        tmpCipherProvider.decrypt(data, 0, data.length, data, 0);

        byte[] verifyChecksum = getMD5Checksum(data);

        if(!MessageDigest.isEqual(originalChecksum,verifyChecksum))
        {
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      muckLength = AES_IV_LENGTH;   

    byte[] muck = getMuckFromBootPassword(bootPassword, muckLength);
    SecretKey key = generateKey(muck);
    byte[] IV = generateIV(muck);
                CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,key,IV);
   
    // store the actual secretKey.length before any possible padding 
    encodedKeyLength = secretKey.length;

    // for the secretKey to be encrypted, first ensure that it is aligned to the block size of the
    // encryption algorithm by padding bytes appropriately if needed
                secretKey = padKey(secretKey,tmpCipherProvider.getEncryptionBlockSize());

                byte[] result = new byte[secretKey.length];

    // encrypt the secretKey using the key generated of muck from  boot password and the generated IV 
    tmpCipherProvider.encrypt(secretKey, 0, secretKey.length, result, 0);

    String hexOutput = org.apache.derby.iapi.util.StringUtil.toHexString(result, 0, result.length);

        return new EncryptedKeyResult( hexOutput, secretKey );
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

    { throw StandardException.newException(SQLState.WRONG_BOOT_PASSWORD); }

        // DERBY-5622:
        // if we survive those two quick checks, verify that the generated key is still correct
        // by using it to decrypt something encrypted by the original generated key
        CipherProvider  newDecrypter = createNewCipher
            ( DECRYPT, generateKey( generatedKey ), IV );
        vetCipherProviders( newDecrypter, verify, SQLState.WRONG_BOOT_PASSWORD );
       
    // Make the new key.  The generated key is unchanged, only the
    // encrypted key is changed.
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      {
        getSecureRandom().nextBytes(data);
        // get the checksum
        byte[] checksum = getMD5Checksum(data);

        CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,mainSecretKey,mainIV);
        tmpCipherProvider.encrypt(data, 0, data.length, data, 0);
        // openFileForWrite
        verifyKeyFile = privAccessFile(sf,Attribute.CRYPTO_EXTERNAL_KEY_VERIFY_FILE,"rw");
        // write the checksum length as int, and then the checksum and then the encrypted data
        verifyKeyFile.writeInt(checksum.length);
        verifyKeyFile.write(checksum);
        verifyKeyFile.write(data);
                verifyKeyFile.sync();
      }
      else
      {
        // Read from verifyKey.dat as an InputStream. This allows for
                // reading the information from verifyKey.dat successfully even when using the jar
                // subprotocol to boot derby. (DERBY-1373)
        verifyKeyInputStream = privAccessGetInputStream(sf,Attribute.CRYPTO_EXTERNAL_KEY_VERIFY_FILE);
                DataInputStream dis = new DataInputStream(verifyKeyInputStream);
        // then read the checksum length
        int checksumLen = dis.readInt();

        byte[] originalChecksum = new byte[checksumLen];
        dis.readFully(originalChecksum);

        dis.readFully(data);

        // decrypt data with key
        CipherProvider tmpCipherProvider = createNewCipher(DECRYPT,mainSecretKey,mainIV);
        tmpCipherProvider.decrypt(data, 0, data.length, data, 0);

        byte[] verifyChecksum = getMD5Checksum(data);

        if(!MessageDigest.isEqual(originalChecksum,verifyChecksum))
        {
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      muckLength = AES_IV_LENGTH;   

    byte[] muck = getMuckFromBootPassword(bootPassword, muckLength);
    SecretKey key = generateKey(muck);
    byte[] IV = generateIV(muck);
                CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,key,IV);
   
    // store the actual secretKey.length before any possible padding 
    encodedKeyLength = secretKey.length;

    // for the secretKey to be encrypted, first ensure that it is aligned to the block size of the
    // encryption algorithm by padding bytes appropriately if needed
                secretKey = padKey(secretKey,tmpCipherProvider.getEncryptionBlockSize());

                byte[] result = new byte[secretKey.length];

    // encrypt the secretKey using the key generated of muck from  boot password and the generated IV 
    tmpCipherProvider.encrypt(secretKey, 0, secretKey.length, result, 0);

    String hexOutput = org.apache.derby.iapi.util.StringUtil.toHexString(result, 0, result.length);

        return new EncryptedKeyResult( hexOutput, secretKey );
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      {
        getSecureRandom().nextBytes(data);
        // get the checksum
        byte[] checksum = getMD5Checksum(data);

        CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,mainSecretKey,mainIV);
        tmpCipherProvider.encrypt(data, 0, data.length, data, 0);
        // openFileForWrite
        verifyKeyFile = privAccessFile(sf,Attribute.CRYPTO_EXTERNAL_KEY_VERIFY_FILE,"rw");
        // write the checksum length as int, and then the checksum and then the encrypted data
        verifyKeyFile.writeInt(checksum.length);
        verifyKeyFile.write(checksum);
        verifyKeyFile.write(data);
        verifyKeyFile.sync(true);
      }
      else
      {
        // Read from verifyKey.dat as an InputStream. This allows for
                // reading the information from verifyKey.dat successfully even when using the jar
                // subprotocol to boot derby. (DERBY-1373)
        verifyKeyInputStream = privAccessGetInputStream(sf,Attribute.CRYPTO_EXTERNAL_KEY_VERIFY_FILE);
                DataInputStream dis = new DataInputStream(verifyKeyInputStream);
        // then read the checksum length
        int checksumLen = dis.readInt();

        byte[] originalChecksum = new byte[checksumLen];
        dis.readFully(originalChecksum);

        dis.readFully(data);

        // decrypt data with key
        CipherProvider tmpCipherProvider = createNewCipher(DECRYPT,mainSecretKey,mainIV);
        tmpCipherProvider.decrypt(data, 0, data.length, data, 0);

        byte[] verifyChecksum = getMD5Checksum(data);

        if(!MessageDigest.isEqual(originalChecksum,verifyChecksum))
        {
View Full Code Here

Examples of org.apache.derby.iapi.services.crypto.CipherProvider

      muckLength = AES_IV_LENGTH;   

    byte[] muck = getMuckFromBootPassword(bootPassword, muckLength);
    SecretKey key = generateKey(muck);
    byte[] IV = generateIV(muck);
                CipherProvider tmpCipherProvider = createNewCipher(ENCRYPT,key,IV);
   
    // store the actual secretKey.length before any possible padding 
    encodedKeyLength = secretKey.length;

    // for the secretKey to be encrypted, first ensure that it is aligned to the block size of the
    // encryption algorithm by padding bytes appropriately if needed
                secretKey = padKey(secretKey,tmpCipherProvider.getEncryptionBlockSize());

                byte[] result = new byte[secretKey.length];

    // encrypt the secretKey using the key generated of muck from  boot password and the generated IV 
    tmpCipherProvider.encrypt(secretKey, 0, secretKey.length, result, 0);

    String hexOutput = org.apache.derby.iapi.util.StringUtil.toHexString(result, 0, result.length);

        return new EncryptedKeyResult( hexOutput, secretKey );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.