-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from jvkersch/header-stream
Support for storing header and data in separate files
- Loading branch information
Showing
9 changed files
with
115 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ | |
|
||
|
||
__title__ = 'GA4GH cryptographic utilities' | ||
__version__ = '1.6' # VERSION in header is 1 (as 4 bytes little endian) | ||
__version__ = '1.7' # VERSION in header is 1 (as 4 bytes little endian) | ||
__author__ = 'Frédéric Haziza' | ||
__author_email__ = '[email protected]' | ||
__license__ = 'Apache License 2.0' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bats | ||
|
||
load _common/helpers | ||
|
||
function setup() { | ||
|
||
# Defining the TMP dir | ||
TESTFILES=${BATS_TEST_FILENAME}.d | ||
mkdir -p "$TESTFILES" | ||
|
||
} | ||
|
||
function teardown() { | ||
rm -rf ${TESTFILES} | ||
} | ||
|
||
@test "Bob sends the testfile secretly (with separate header and data) to Alice" { | ||
|
||
TESTFILE=${BATS_TEST_DIRNAME}/_common/testfile.abcd | ||
|
||
# Bob encrypts the testfile for Alice, storing the header separately | ||
export C4GH_PASSPHRASE=${BOB_PASSPHRASE} | ||
crypt4gh encrypt --sk ${BOB_SECKEY} --recipient_pk ${ALICE_PUBKEY} --header $TESTFILES/header.alice.c4gh < $TESTFILE > $TESTFILES/data.c4gh | ||
|
||
# Alice concatenates the header and the data and decrypts the combined result | ||
export C4GH_PASSPHRASE=${ALICE_PASSPHRASE} | ||
cat $TESTFILES/header.alice.c4gh $TESTFILES/data.c4gh | crypt4gh decrypt --sk ${ALICE_SECKEY} > $TESTFILES/message.received | ||
|
||
run diff $TESTFILE $TESTFILES/message.received | ||
[ "$status" -eq 0 ] | ||
|
||
unset C4GH_PASSPHRASE | ||
} | ||
|
||
@test "Bob encrypts the testfile for himself (with separate header) and reencrypts the header for Alice" { | ||
|
||
TESTFILE=${BATS_TEST_DIRNAME}/_common/testfile.abcd | ||
|
||
# Bob encrypts the testfile for himself | ||
export C4GH_PASSPHRASE=${BOB_PASSPHRASE} | ||
crypt4gh encrypt --sk ${BOB_SECKEY} --recipient_pk ${BOB_PUBKEY} --header $TESTFILES/header.bob.c4gh < $TESTFILE > $TESTFILES/data.c4gh | ||
|
||
# Bob changes the header for Alice | ||
crypt4gh reencrypt --sk ${BOB_SECKEY} --recipient_pk ${ALICE_PUBKEY} --header-only < $TESTFILES/header.bob.c4gh > $TESTFILES/header.alice.c4gh | ||
|
||
# Alice concatenates the header and data and decrypts the results | ||
export C4GH_PASSPHRASE=${ALICE_PASSPHRASE} | ||
cat $TESTFILES/header.alice.c4gh $TESTFILES/data.c4gh | crypt4gh decrypt --sk ${ALICE_SECKEY} > $TESTFILES/message.received | ||
|
||
run diff $TESTFILE $TESTFILES/message.received | ||
[ "$status" -eq 0 ] | ||
|
||
unset C4GH_PASSPHRASE | ||
} |