Skip to content

Commit

Permalink
Prepend a byte in the file format
Browse files Browse the repository at this point in the history
The prepended byte is supposed to indicate the version of the file
format. This is added for forward compatibility.
  • Loading branch information
kinoru committed Dec 5, 2015
1 parent acb2a8d commit b12440a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Change Log

## 0.1.0 - 2015-12-05

- Prepended a single byte in the encrypted file format to indicate the "version number." The byte isn't really used for anything useful yet; it's for forward compatibility.
6 changes: 4 additions & 2 deletions lib/Unbreak/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ editRemoteFile conf@Conf{..} filename = do
-- copy the remote file to the shelf
tryRun (mconcat ["scp ", remoteFilePath, " ", rawFilePath])
-- if there is a file, decrypt it
( decrypt master <$> B.readFile rawFilePath >>= \ m -> case m of
( decrypt master <$> B.tail <$> B.readFile rawFilePath >>=
\ m -> case m of
CryptoPassed plaintext -> B.writeFile filePath plaintext
CryptoFailed e -> do
B.putStrLn $ "Decryption failed. " ++ B.pack (show e)
Expand All @@ -124,7 +125,8 @@ editRemoteFile conf@Conf{..} filename = do
edited <- B.readFile filePath
nonce <- getRandomBytes 12
B.writeFile rawFilePath $
throwCryptoError $ encrypt nonce master edited
-- adding the version number, for forward compatibility
"\0" ++ (throwCryptoError $ encrypt nonce master edited)
-- upload the file from the shelf to the remote
run (mconcat ["scp ", rawFilePath, " ", remoteFilePath]) $
\ n -> B.putStrLn $ mconcat
Expand Down

0 comments on commit b12440a

Please sign in to comment.