public PdfFile(string filename) { Info = new FileInfo(filename); EncryptionRecordInfo = new EncryptionRecord() { isEncrypted = false, PasswordCharset = CharsetEncoding.Ascii, encryptionType = PdfEncryptionType.None, MaxPasswordSize = Constants.MaxPasswordSize }; }
protected RC4DecryptorBase(EncryptionRecord encryptionInfo) { state = new byte[256]; userKey = new byte[32]; permission = new byte[4]; arrayMath = new ArrayMath(); md5 = new MD5CryptoServiceProvider(); mkey = new byte[encryptionInfo.keyLength / 8]; digest = new byte[encryptionInfo.keyLength / 8]; permission[0] = (byte)encryptionInfo.pValue; permission[1] = (byte)(encryptionInfo.pValue >> 8); permission[2] = (byte)(encryptionInfo.pValue >> 16); permission[3] = (byte)(encryptionInfo.pValue >> 24); }
public AESISODecryptor256Bit(EncryptionRecord encryptionInfo) : base() { EncryptionInfo = encryptionInfo; sha256 = new SHA256CryptoServiceProvider(); sha384 = new SHA384CryptoServiceProvider(); sha512 = new SHA512CryptoServiceProvider(); arrayMath = new ArrayMath(); aes = new AesCryptoServiceProvider() { Mode = CipherMode.CBC, Padding = PaddingMode.None, BlockSize = 128, KeySize = 128 }; }
public static IDecryptor Get(EncryptionRecord encryptionInfo) { switch (encryptionInfo.encryptionType) { case PdfEncryptionType.StandardEncryption40Bit: return(new RC4Decryptor40Bit(encryptionInfo)); case PdfEncryptionType.StandardEncryption128Bit: case PdfEncryptionType.AesEncryption128Bit: return(new RC4Decryptor128Bit(encryptionInfo)); case PdfEncryptionType.AesEncryption256Bit: return(new AESDecryptor256Bit(encryptionInfo)); case PdfEncryptionType.AesIsoEncryption256Bit: return(new AESISODecryptor256Bit(encryptionInfo)); default: throw new Exception("Unsupported encryption type."); } }
public PdfLoginViewModel(Window pdfLoginWindow, EncryptionRecord encryptionRecord) { PdfDecryptor = DecryptorFactory.Get(encryptionRecord); pdfLoginView = pdfLoginWindow; InitializeCommands(); }
public AESDecryptor256Bit(EncryptionRecord encryptionInfo) { EncryptionInfo = encryptionInfo; sha256 = new SHA256CryptoServiceProvider(); arrayMath = new ArrayMath(); }
public static DocumentEntry CreateEncryptionEntry(DirectoryEntry dir, String path, EncryptionRecord out1) { String[] parts = path.Split("/".ToCharArray()); for (int i = 0; i < parts.Length - 1; i++) { dir = dir.HasEntry(parts[i]) ? (DirectoryEntry)dir.GetEntry(parts[i]) : dir.CreateDirectory(parts[i]); } byte[] buf = new byte[5000]; LittleEndianByteArrayOutputStream bos = new LittleEndianByteArrayOutputStream(buf, 0); out1.Write(bos); String fileName = parts[parts.Length - 1]; if (dir.HasEntry(fileName)) { dir.GetEntry(fileName).Delete(); } return(dir.CreateDocument(fileName, bos.WriteIndex, new POIFSWriterListenerImpl(buf))); }
public RC4Decryptor40Bit(EncryptionRecord encryptionInfo) : base(encryptionInfo) { EncryptionInfo = encryptionInfo; }