@Override public void setKeySize(int keyBits) { // Microsoft Base Cryptographic Provider is limited up to 40 bits // http://msdn.microsoft.com/en-us/library/windows/desktop/aa375599(v=vs.85).aspx boolean found = false; for (int size : getCipherAlgorithm().allowedKeySize) { if (size == keyBits) { found = true; break; } } if (!found) { throw new EncryptedDocumentException("invalid keysize "+keyBits+" for cipher algorithm "+getCipherAlgorithm()); } super.setKeySize(keyBits); if (keyBits > 40) { setCspName("Microsoft Enhanced Cryptographic Provider v1.0"); } else { setCspName(CipherProvider.rc4.cipherProviderName); } }
protected StandardEncryptionHeader(CipherAlgorithm cipherAlgorithm, HashAlgorithm hashAlgorithm, int keyBits, int blockSize, ChainingMode chainingMode) { setCipherAlgorithm(cipherAlgorithm); setHashAlgorithm(hashAlgorithm); setKeySize(keyBits); setBlockSize(blockSize); setCipherProvider(cipherAlgorithm.provider); setFlags(flagCryptoAPI.setBoolean(0, true) | flagAES.setBoolean(0, cipherAlgorithm.provider == CipherProvider.aes)); // see http://msdn.microsoft.com/en-us/library/windows/desktop/bb931357(v=vs.85).aspx for a full list // setCspName("Microsoft Enhanced RSA and AES Cryptographic Provider"); }
setKeySize(keySize); setBlockSize(getKeySize()); setCipherProvider(CipherProvider.fromEcmaId(is.readInt()));
@Override public void setKeySize(int keyBits) { // Microsoft Base Cryptographic Provider is limited up to 40 bits // http://msdn.microsoft.com/en-us/library/windows/desktop/aa375599(v=vs.85).aspx boolean found = false; for (int size : getCipherAlgorithm().allowedKeySize) { if (size == keyBits) { found = true; break; } } if (!found) { throw new EncryptedDocumentException("invalid keysize "+keyBits+" for cipher algorithm "+getCipherAlgorithm()); } super.setKeySize(keyBits); if (keyBits > 40) { setCspName("Microsoft Enhanced Cryptographic Provider v1.0"); } else { setCspName(CipherProvider.rc4.cipherProviderName); } }
protected StandardEncryptionHeader(CipherAlgorithm cipherAlgorithm, HashAlgorithm hashAlgorithm, int keyBits, int blockSize, ChainingMode chainingMode) { setCipherAlgorithm(cipherAlgorithm); setHashAlgorithm(hashAlgorithm); setKeySize(keyBits); setBlockSize(blockSize); setCipherProvider(cipherAlgorithm.provider); setFlags(flagCryptoAPI.setBoolean(0, true) | flagAES.setBoolean(0, cipherAlgorithm.provider == CipherProvider.aes)); // see http://msdn.microsoft.com/en-us/library/windows/desktop/bb931357(v=vs.85).aspx for a full list // setCspName("Microsoft Enhanced RSA and AES Cryptographic Provider"); }
setKeySize(keySize); setBlockSize(getKeySize()); setCipherProvider(CipherProvider.fromEcmaId(is.readInt()));