/** * Constructs an EncryptionInfo from scratch * * @param encryptionMode see {@link EncryptionMode} for values, {@link EncryptionMode#cryptoAPI} is for * internal use only, as it's record based * @param cipherAlgorithm * @param hashAlgorithm * @param keyBits * @param blockSize * @param chainingMode * * @throws EncryptedDocumentException if the given parameters mismatch, e.g. only certain combinations * of keyBits, blockSize are allowed for a given {@link CipherAlgorithm} */ public EncryptionInfo( EncryptionMode encryptionMode , CipherAlgorithm cipherAlgorithm , HashAlgorithm hashAlgorithm , int keyBits , int blockSize , ChainingMode chainingMode ) { _versionMajor = encryptionMode.VersionMajor; _versionMinor = encryptionMode.VersionMinor; _encryptionFlags = encryptionMode.EncryptionFlags; IEncryptionInfoBuilder eib; try { eib = GetBuilder(encryptionMode); } catch (Exception e) { throw new EncryptedDocumentException(e); } eib.Initialize(this, cipherAlgorithm, hashAlgorithm, keyBits, blockSize, chainingMode); _header = eib.GetHeader(); _verifier = eib.GetVerifier(); _decryptor = eib.GetDecryptor(); _encryptor = eib.GetEncryptor(); }
/** * @deprecated use {@link #EncryptionInfo(EncryptionMode, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode)} */ public EncryptionInfo( DirectoryNode dir , EncryptionMode encryptionMode , CipherAlgorithm cipherAlgorithm , HashAlgorithm hashAlgorithm , int keyBits , int blockSize , ChainingMode chainingMode ) : this(encryptionMode, cipherAlgorithm, hashAlgorithm, keyBits, blockSize, chainingMode) { ; }
/** * @deprecated use {@link #EncryptionInfo(EncryptionMode, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode)} */ public EncryptionInfo( NPOIFSFileSystem fs , EncryptionMode encryptionMode , CipherAlgorithm cipherAlgorithm , HashAlgorithm hashAlgorithm , int keyBits , int blockSize , ChainingMode chainingMode ) : this(encryptionMode, cipherAlgorithm, hashAlgorithm, keyBits, blockSize, chainingMode) { ; }
protected static IEncryptionInfoBuilder GetBuilder(EncryptionMode encryptionMode) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Type t = null; foreach (Assembly assembly in assemblies) { t = assembly.GetType(encryptionMode.Builder); if (t != null) { break; } } if (t == null) { throw new EncryptedDocumentException("Not found type " + encryptionMode.Builder); } IEncryptionInfoBuilder eib = null; eib = (IEncryptionInfoBuilder)t.Assembly.CreateInstance(encryptionMode.Builder); return(eib); }
/** * Prepares for encryption, using the given Encryption Mode, and * all other parameters as default. * @see #EncryptionInfo(EncryptionMode, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode) */ public EncryptionInfo(EncryptionMode encryptionMode) : this(encryptionMode, null, null, -1, -1, null) { }
/** * @deprecated Use {@link #EncryptionInfo(EncryptionMode)} (dir parameter no longer required) */ public EncryptionInfo(DirectoryNode dir, EncryptionMode encryptionMode) : this(encryptionMode) { ; }
/** * @deprecated Use {@link #EncryptionInfo(EncryptionMode)} (fs parameter no longer required) */ public EncryptionInfo(NPOIFSFileSystem fs, EncryptionMode encryptionMode) : this(encryptionMode) { ; }