summaryrefslogtreecommitdiff
path: root/notes/lib_crypto
diff options
context:
space:
mode:
Diffstat (limited to 'notes/lib_crypto')
-rw-r--r--notes/lib_crypto/CipherContext.txt28
-rw-r--r--notes/lib_crypto/RollingChecksum.txt36
2 files changed, 64 insertions, 0 deletions
diff --git a/notes/lib_crypto/CipherContext.txt b/notes/lib_crypto/CipherContext.txt
new file mode 100644
index 00000000..30fb4608
--- /dev/null
+++ b/notes/lib_crypto/CipherContext.txt
@@ -0,0 +1,28 @@
+CLASS CipherContext
+
+Encryption and decryption using OpenSSL EVP interface.
+
+See the cpp file for more documentation in the function headers, and test/crypto for examples.
+
+General notes below.
+
+
+SUBTITLE Construction
+
+Construct with the encryption direction, and a CipherDescription of the cipher and key required.
+
+
+SUBTITLE Encrypting or decrypting
+
+Begin() and Transform() allow piece by piece transformation of a block.
+
+TransformBlock() transforms an entire block.
+
+
+SUBTITLE Buffering
+
+All transforms expect to have enough space in the buffers for their entire output. Because of block boundaries and padding, it is necessary that the output buffer should be bigger than the input buffer. The amount of space depends on the cipher.
+
+InSizeForOutBufferSize() and MaxOutSizeForInBufferSize() perform these space calculations, returning the maximuim in size for a specified out size, and the reverse, respectively.
+
+
diff --git a/notes/lib_crypto/RollingChecksum.txt b/notes/lib_crypto/RollingChecksum.txt
new file mode 100644
index 00000000..d871b3f2
--- /dev/null
+++ b/notes/lib_crypto/RollingChecksum.txt
@@ -0,0 +1,36 @@
+CLASS RollingChecksum
+
+Implementing the rsync rolling checksum algorithm. Read it's description first:
+
+http://samba.anu.edu.au/rsync/tech_report/node3.html
+
+
+SUBTITLE Construction and initial checksum calculation
+
+The constructor takes a pointer to a block of data and a size, and calculates the checksum of this block. It can now be "rolled forward" to find the checksum of the block of the same size, one byte forward, with minimal calculation.
+
+
+FUNCTION RollingChecksum::GetChecksum()
+
+Returns the checksum for the current block.
+
+
+FUNCTION RollingChecksum::RollForward()
+
+This function takes the byte at the start of the current block, and the last byte of the block it's rolling forward to, and moves the checksum on.
+
+If the block is
+
+ char *pBlock = <something>;
+
+with size s, then it should be called with
+
+ RollForward(pBlock[0], pBlock[s])
+
+and now GetChecksum will return the checksum of the block (pBlock+1) of size s.
+
+
+FUNCTION RollingChecksum::RollForwardSeveral()
+
+Similar to RollForward(), but is more efficient for skipping several bytes at once. Takes pointers to the data buffer rather than the actual data values.
+