Examples of EncryptionVerifier


Examples of org.apache.poi.poifs.crypt.EncryptionVerifier

    protected StandardDecryptor(EncryptionInfo info) {
        super(info);
    }

    public boolean verifyPassword(String password) {
        EncryptionVerifier ver = info.getVerifier();
        SecretKey skey = generateSecretKey(password, ver, getKeySizeInBytes());
        Cipher cipher = getCipher(skey);

        try {
            byte encryptedVerifier[] = ver.getEncryptedVerifier();
            byte verifier[] = cipher.doFinal(encryptedVerifier);
            setVerifier(verifier);
            MessageDigest sha1 = CryptoFunctions.getMessageDigest(ver.getHashAlgorithm());
            byte[] calcVerifierHash = sha1.digest(verifier);
            byte encryptedVerifierHash[] = ver.getEncryptedVerifierHash();
            byte decryptedVerifierHash[] = cipher.doFinal(encryptedVerifierHash);
            byte[] verifierHash = truncateOrPad(decryptedVerifierHash, calcVerifierHash.length);
   
            if (Arrays.equals(calcVerifierHash, verifierHash)) {
                setSecretKey(skey);
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionVerifier

        }
       
    }

    private Cipher getCipher(SecretKey key, String padding) {
        EncryptionVerifier ver = builder.getVerifier();
        return CryptoFunctions.getCipher(key, ver.getCipherAlgorithm(), ver.getChainingMode(), null, Cipher.ENCRYPT_MODE, padding);
    }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionVerifier

        }
       
    }

    private Cipher getCipher(SecretKey key, String padding) {
        EncryptionVerifier ver = builder.getVerifier();
        return CryptoFunctions.getCipher(key, ver.getCipherAlgorithm(), ver.getChainingMode(), null, Cipher.ENCRYPT_MODE, padding);
    }
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionVerifier

    protected StandardDecryptor(EncryptionInfo info) {
        super(info);
    }

    public boolean verifyPassword(String password) {
        EncryptionVerifier ver = info.getVerifier();
        SecretKey skey = generateSecretKey(password, ver, getKeySizeInBytes());
        Cipher cipher = getCipher(skey);

        try {
            byte encryptedVerifier[] = ver.getEncryptedVerifier();
            byte verifier[] = cipher.doFinal(encryptedVerifier);
            setVerifier(verifier);
            MessageDigest sha1 = MessageDigest.getInstance(ver.getHashAlgorithm().jceId);
            byte[] calcVerifierHash = sha1.digest(verifier);
            byte encryptedVerifierHash[] = ver.getEncryptedVerifierHash();
            byte decryptedVerifierHash[] = cipher.doFinal(encryptedVerifierHash);
            byte[] verifierHash = truncateOrPad(decryptedVerifierHash, calcVerifierHash.length);
   
            if (Arrays.equals(calcVerifierHash, verifierHash)) {
                setSecretKey(skey);
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionVerifier

        for (fillSize=blockSize; fillSize<inputLen; fillSize+=blockSize);
        return fillSize;
    }

    protected static byte[] hashInput(AgileEncryptionInfoBuilder builder, byte pwHash[], byte blockKey[], byte inputKey[], int cipherMode) {
        EncryptionVerifier ver = builder.getVerifier();
        int keySize = builder.getDecryptor().getKeySizeInBytes();
        int blockSize = builder.getDecryptor().getBlockSizeInBytes();
        HashAlgorithm hashAlgo = ver.getHashAlgorithm();
        byte[] salt = ver.getSalt();

        byte intermedKey[] = generateKey(pwHash, hashAlgo, blockKey, keySize);
        SecretKey skey = new SecretKeySpec(intermedKey, ver.getCipherAlgorithm().jceId);
        byte[] iv = generateIv(hashAlgo, salt, null, blockSize);
        Cipher cipher = getCipher(skey, ver.getCipherAlgorithm(), ver.getChainingMode(), iv, cipherMode);
        byte[] hashFinal;
       
        try {
            inputKey = getBlock0(inputKey, getNextBlockSize(inputKey.length, blockSize));
            hashFinal = cipher.doFinal(inputKey);
View Full Code Here

Examples of org.apache.poi.poifs.crypt.EncryptionVerifier

    protected StandardDecryptor(EncryptionInfo info) {
        super(info);
    }

    public boolean verifyPassword(String password) {
        EncryptionVerifier ver = info.getVerifier();
        SecretKey skey = generateSecretKey(password, ver, getKeySizeInBytes());
        Cipher cipher = getCipher(skey);

        try {
            byte encryptedVerifier[] = ver.getEncryptedVerifier();
            byte verifier[] = cipher.doFinal(encryptedVerifier);
            setVerifier(verifier);
            MessageDigest sha1 = CryptoFunctions.getMessageDigest(ver.getHashAlgorithm());
            byte[] calcVerifierHash = sha1.digest(verifier);
            byte encryptedVerifierHash[] = ver.getEncryptedVerifierHash();
            byte decryptedVerifierHash[] = cipher.doFinal(encryptedVerifierHash);
            byte[] verifierHash = truncateOrPad(decryptedVerifierHash, calcVerifierHash.length);
   
            if (Arrays.equals(calcVerifierHash, verifierHash)) {
                setSecretKey(skey);
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.