コード例 #1
0
        private static byte[] EncryptFileHeader(string inputFilePath, byte[] ephemeralPublicKey, byte[] dataEncryptionKey, byte[] nonce, byte[] keyEncryptionKey)
        {
            long fileLength = FileHandling.GetFileLength(inputFilePath);

            byte[] lastChunkLength = BitConversion.GetBytes(Convert.ToInt32(fileLength % Constants.FileChunkSize));
            byte[] fileNameLength  = FileHeaders.GetFileNameLength(inputFilePath);
            byte[] fileHeader      = Arrays.Concat(lastChunkLength, fileNameLength, dataEncryptionKey);
            byte[] additionalData  = HeaderEncryption.ComputeAdditionalData(fileLength, ephemeralPublicKey);
            return(HeaderEncryption.Encrypt(fileHeader, nonce, keyEncryptionKey, additionalData));
        }
コード例 #2
0
ファイル: EncryptFile.cs プロジェクト: smalltsky/Kryptor
        private static byte[] EncryptFileHeader(string inputFilePath, byte[] dataEncryptionKey, byte[] nonce, byte[] keyEncryptionKey)
        {
            byte[] keyCommitmentBlock = ChunkHandling.GetKeyCommitmentBlock();
            long   fileLength         = FileHandling.GetFileLength(inputFilePath);

            byte[] lastChunkLength = BitConverter.GetBytes(Convert.ToInt32(fileLength % Constants.FileChunkSize));
            byte[] fileNameLength  = FileHeaders.GetFileNameLength(inputFilePath);
            byte[] fileHeader      = Utilities.ConcatArrays(keyCommitmentBlock, lastChunkLength, fileNameLength, dataEncryptionKey);
            byte[] additionalData  = HeaderEncryption.ComputeAdditionalData(fileLength);
            return(HeaderEncryption.Encrypt(fileHeader, nonce, keyEncryptionKey, additionalData));
        }
コード例 #3
0
 private static byte[] DecryptFileHeader(string inputFilePath, byte[] encryptedHeader, byte[] nonce, byte[] keyEncryptionKey)
 {
     byte[] additionalData = HeaderEncryption.GetAdditionalData(inputFilePath);
     return(HeaderEncryption.Decrypt(encryptedHeader, nonce, keyEncryptionKey, additionalData));
 }
コード例 #4
0
 private static byte[] DecryptFileHeader(FileStream inputFile, byte[] ephemeralPublicKey, byte[] encryptedHeader, byte[] nonce, byte[] keyEncryptionKey)
 {
     byte[] additionalData = HeaderEncryption.GetAdditionalData(inputFile, ephemeralPublicKey);
     return(HeaderEncryption.Decrypt(encryptedHeader, nonce, keyEncryptionKey, additionalData));
 }