)]}'
{"test/unit/common/middleware/test_crypto_utils.py":[{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"da82321d8811f3efa73d79f2b8c1ca08c22180a4","unresolved":false,"context_lines":[{"line_number":250,"context_line":"                ValueError, self.crypto.create_encryption_ctxt, bad_key, iv)"},{"line_number":251,"context_line":""},{"line_number":252,"context_line":"    def test_create_decryption_context(self):"},{"line_number":253,"context_line":"        # TODO: add tests here for non-zero offset"},{"line_number":254,"context_line":"        value \u003d \u0027decrypt me\u0027 * 100  # more than one cipher block"},{"line_number":255,"context_line":"        key \u003d os.urandom(32)"},{"line_number":256,"context_line":"        iv \u003d os.urandom(16)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_f875b331","line":253,"updated":"2016-06-08 15:50:47.000000000","message":"this TODO can be deleted?","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":12261,"name":"Mahati","email":"mahati.chamarthy@gmail.com","username":"Mahati"},"change_message_id":"371fe576c07b00b1b0d6b4302ac44a7dca4d890a","unresolved":false,"context_lines":[{"line_number":250,"context_line":"                ValueError, self.crypto.create_encryption_ctxt, bad_key, iv)"},{"line_number":251,"context_line":""},{"line_number":252,"context_line":"    def test_create_decryption_context(self):"},{"line_number":253,"context_line":"        # TODO: add tests here for non-zero offset"},{"line_number":254,"context_line":"        value \u003d \u0027decrypt me\u0027 * 100  # more than one cipher block"},{"line_number":255,"context_line":"        key \u003d os.urandom(32)"},{"line_number":256,"context_line":"        iv \u003d os.urandom(16)"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_a5ee3b1f","line":253,"in_reply_to":"7aa08908_f875b331","updated":"2016-06-09 07:59:20.000000000","message":"Done","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"da82321d8811f3efa73d79f2b8c1ca08c22180a4","unresolved":false,"context_lines":[{"line_number":307,"context_line":"                         \u0027Expected value {%s} but got {%s}\u0027 %"},{"line_number":308,"context_line":"                         (\u0027456789abc\u0027, \u0027\u0027.join(dec_val)))"},{"line_number":309,"context_line":""},{"line_number":310,"context_line":"    def test_iv_with_offset(self):"},{"line_number":311,"context_line":"        # Test iv with offset \u003e 0 and offset \u003c 0"},{"line_number":312,"context_line":"        iv \u003d self.crypto.create_iv()"},{"line_number":313,"context_line":"        offset \u003d [-1, 2]"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_98f62f8d","line":310,"updated":"2016-06-08 15:50:47.000000000","message":"could the test name refer to the method being tested e.g. test_create_decryption_context_non_zero_offset\n\nor just be included in existing test_create_decryption_context?","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":12261,"name":"Mahati","email":"mahati.chamarthy@gmail.com","username":"Mahati"},"change_message_id":"371fe576c07b00b1b0d6b4302ac44a7dca4d890a","unresolved":false,"context_lines":[{"line_number":307,"context_line":"                         \u0027Expected value {%s} but got {%s}\u0027 %"},{"line_number":308,"context_line":"                         (\u0027456789abc\u0027, \u0027\u0027.join(dec_val)))"},{"line_number":309,"context_line":""},{"line_number":310,"context_line":"    def test_iv_with_offset(self):"},{"line_number":311,"context_line":"        # Test iv with offset \u003e 0 and offset \u003c 0"},{"line_number":312,"context_line":"        iv \u003d self.crypto.create_iv()"},{"line_number":313,"context_line":"        offset \u003d [-1, 2]"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_45e03729","line":310,"in_reply_to":"7aa08908_98f62f8d","updated":"2016-06-09 07:59:20.000000000","message":"Done","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":12279,"name":"Janie Richling","email":"jrichli@us.ibm.com","username":"jrichli"},"change_message_id":"0505326d094e63d107e37752e36c5d423ccc12c2","unresolved":false,"context_lines":[{"line_number":307,"context_line":"                         \u0027Expected value {%s} but got {%s}\u0027 %"},{"line_number":308,"context_line":"                         (\u0027456789abc\u0027, \u0027\u0027.join(dec_val)))"},{"line_number":309,"context_line":""},{"line_number":310,"context_line":"    def test_iv_with_offset(self):"},{"line_number":311,"context_line":"        # Test iv with offset \u003e 0 and offset \u003c 0"},{"line_number":312,"context_line":"        iv \u003d self.crypto.create_iv()"},{"line_number":313,"context_line":"        offset \u003d [-1, 2]"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_de489fb5","line":310,"in_reply_to":"7aa08908_98f62f8d","updated":"2016-06-08 16:12:16.000000000","message":"I would take this a step farther and focus on a generic body that is decrypted.\n\nThe non-zero offset case is for decrypting a sub-set of the whole message.  This will never be the case for an iv, so the example is confusing.  Maybe just call it a message or a body.\n\nbtw - test_decrypt_range does cover the \u0027non-zero case\u0027 lines in the code already.  I was wondering if we just wanted more tests like that - but more variety.  Like Alistair asked about different offsets.","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"da82321d8811f3efa73d79f2b8c1ca08c22180a4","unresolved":false,"context_lines":[{"line_number":310,"context_line":"    def test_iv_with_offset(self):"},{"line_number":311,"context_line":"        # Test iv with offset \u003e 0 and offset \u003c 0"},{"line_number":312,"context_line":"        iv \u003d self.crypto.create_iv()"},{"line_number":313,"context_line":"        offset \u003d [-1, 2]"},{"line_number":314,"context_line":"        key \u003d \u0027objL7wjV6L79Sfs4y7dy41273l0k6Wki\u0027"},{"line_number":315,"context_line":"        for val in offset:"},{"line_number":316,"context_line":"            if offset \u003c 0:"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_b34eac38","line":313,"updated":"2016-06-08 15:50:47.000000000","message":"are there any other \"interesting\" vals to test - e.g. offset \u003e\u003d 16, all offsets in range of 0-15 should get the same iv, ditto all offsets in range (n*16 to n*16 + 15).","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":12261,"name":"Mahati","email":"mahati.chamarthy@gmail.com","username":"Mahati"},"change_message_id":"371fe576c07b00b1b0d6b4302ac44a7dca4d890a","unresolved":false,"context_lines":[{"line_number":310,"context_line":"    def test_iv_with_offset(self):"},{"line_number":311,"context_line":"        # Test iv with offset \u003e 0 and offset \u003c 0"},{"line_number":312,"context_line":"        iv \u003d self.crypto.create_iv()"},{"line_number":313,"context_line":"        offset \u003d [-1, 2]"},{"line_number":314,"context_line":"        key \u003d \u0027objL7wjV6L79Sfs4y7dy41273l0k6Wki\u0027"},{"line_number":315,"context_line":"        for val in offset:"},{"line_number":316,"context_line":"            if offset \u003c 0:"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_05dc6f44","line":313,"in_reply_to":"7aa08908_b34eac38","updated":"2016-06-09 07:59:20.000000000","message":"I think I put in some interesting values now (in patchset 2). Thanks for pointing it out! It also revealed a small bug in the test.","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"da82321d8811f3efa73d79f2b8c1ca08c22180a4","unresolved":false,"context_lines":[{"line_number":313,"context_line":"        offset \u003d [-1, 2]"},{"line_number":314,"context_line":"        key \u003d \u0027objL7wjV6L79Sfs4y7dy41273l0k6Wki\u0027"},{"line_number":315,"context_line":"        for val in offset:"},{"line_number":316,"context_line":"            if offset \u003c 0:"},{"line_number":317,"context_line":"                with self.assertRaises(ValueError) as cm:"},{"line_number":318,"context_line":"                    self.crypto.create_decryption_ctxt(key, iv, offset)"},{"line_number":319,"context_line":"                self.assertEqual(\"Offset must not be negative\","}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_5885e7cc","line":316,"updated":"2016-06-08 15:50:47.000000000","message":"this is already covered at line 273 (although the assertion on exception message is a useful addition, but that could be made at line 273)","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":12261,"name":"Mahati","email":"mahati.chamarthy@gmail.com","username":"Mahati"},"change_message_id":"371fe576c07b00b1b0d6b4302ac44a7dca4d890a","unresolved":false,"context_lines":[{"line_number":313,"context_line":"        offset \u003d [-1, 2]"},{"line_number":314,"context_line":"        key \u003d \u0027objL7wjV6L79Sfs4y7dy41273l0k6Wki\u0027"},{"line_number":315,"context_line":"        for val in offset:"},{"line_number":316,"context_line":"            if offset \u003c 0:"},{"line_number":317,"context_line":"                with self.assertRaises(ValueError) as cm:"},{"line_number":318,"context_line":"                    self.crypto.create_decryption_ctxt(key, iv, offset)"},{"line_number":319,"context_line":"                self.assertEqual(\"Offset must not be negative\","}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_e5de833c","line":316,"in_reply_to":"7aa08908_5885e7cc","updated":"2016-06-09 07:59:20.000000000","message":"Done","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"da82321d8811f3efa73d79f2b8c1ca08c22180a4","unresolved":false,"context_lines":[{"line_number":323,"context_line":"                ivl +\u003d int(val / 16) + (1 \u003c\u003c (16 * 8))"},{"line_number":324,"context_line":"                ivstr \u003d format(ivl, \u0027x\u0027)"},{"line_number":325,"context_line":"                iv \u003d str(bytearray.fromhex(ivstr[(len(ivstr) - 2 * 16):]))"},{"line_number":326,"context_line":"                dec_ctxt \u003d self.crypto.create_decryption_ctxt(key, iv, 4)"},{"line_number":327,"context_line":"                self.assertEqual(iv, dec_ctxt.iv)"},{"line_number":328,"context_line":""},{"line_number":329,"context_line":"    def test_check_key(self):"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_133d008f","line":326,"updated":"2016-06-08 15:50:47.000000000","message":"why is the offset passed here \u003d 4? should it no be the val under test?","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":11330,"name":"Christian Cachin","email":"cca@zurich.ibm.com","username":"cca88"},"change_message_id":"f95a23dd61ac072cc92165e6b3b690d6c9d2c5c5","unresolved":false,"context_lines":[{"line_number":324,"context_line":"                ivstr \u003d format(ivl, \u0027x\u0027)"},{"line_number":325,"context_line":"                iv \u003d str(bytearray.fromhex(ivstr[(len(ivstr) - 2 * 16):]))"},{"line_number":326,"context_line":"                dec_ctxt \u003d self.crypto.create_decryption_ctxt(key, iv, 4)"},{"line_number":327,"context_line":"                self.assertEqual(iv, dec_ctxt.iv)"},{"line_number":328,"context_line":""},{"line_number":329,"context_line":"    def test_check_key(self):"},{"line_number":330,"context_line":"        for key in (\u0027objKey\u0027, \u0027a\u0027 * 31, \u0027a\u0027 * 33, \u0027a\u0027 * 16, \u0027a\u0027 * 24):"}],"source_content_type":"text/x-python","patch_set":1,"id":"7aa08908_60ecddbb","line":327,"range":{"start_line":327,"start_character":0,"end_line":327,"end_character":49},"updated":"2016-06-16 17:16:39.000000000","message":"It looks like the test code is the same that also computes this inside crypto_utils. It could be more illustrative to test with a few precomputed values, obtained differently. Also a test that \"wraps around\" by starting with an IV \u003d 2^128 - (small number) and incrementing it by (larger number) could be useful.","commit_id":"0db0735142d7f82ba6968014016580febf98679a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"39f8738e2c822647f7af7fec5234100c848c8a4a","unresolved":false,"context_lines":[{"line_number":271,"context_line":""},{"line_number":272,"context_line":"        with self.assertRaises(ValueError) as cm:"},{"line_number":273,"context_line":"            self.crypto.create_decryption_ctxt(key, iv, -1)"},{"line_number":274,"context_line":"        self.assertEqual(\"Offset must not be negative\", cm.exception.message)"},{"line_number":275,"context_line":""},{"line_number":276,"context_line":"    def test_enc_dec_small_chunks(self):"},{"line_number":277,"context_line":"        self.enc_dec_chunks([\u0027encrypt me\u0027, \u0027because I\u0027, \u0027am sensitive\u0027])"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_be1acc7a","line":274,"updated":"2016-06-09 09:17:45.000000000","message":"+1","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"39f8738e2c822647f7af7fec5234100c848c8a4a","unresolved":false,"context_lines":[{"line_number":299,"context_line":"        enc_val \u003d [enc_ctxt.update(chunk) for chunk in chunks]"},{"line_number":300,"context_line":"        self.assertTrue(\u0027\u0027.join(enc_val) !\u003d chunks)"},{"line_number":301,"context_line":""},{"line_number":302,"context_line":"        # Simulate a ranged GET from byte 4 to 12 : \u0027456789abc\u0027"},{"line_number":303,"context_line":"        dec_ctxt \u003d self.crypto.create_decryption_ctxt(key, iv, 4)"},{"line_number":304,"context_line":"        ranged_chunks \u003d [enc_val[0][4:], enc_val[1], enc_val[2][:3]]"},{"line_number":305,"context_line":"        dec_val \u003d [dec_ctxt.update(chunk) for chunk in ranged_chunks]"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_7e2ea4a5","line":302,"updated":"2016-06-09 09:17:45.000000000","message":"now I have a better understanding of the offset to iv mapping I realise that this particular range does not result in a different iv since the offset is \u003c15. We should improve this test to use longer chunks and select a range that (a) spans two 16byte \u0027frames\u0027 and (b) starts beyond 16 bytes offset.\n\nAs it is I can comment out the iv recalculation in create_decryption_context and this test will still pass because the offset iv needed is equal to the iv given anyway.","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":12279,"name":"Janie Richling","email":"jrichli@us.ibm.com","username":"jrichli"},"change_message_id":"5531b3c20eb79019c1878ec0806b79f49fe55196","unresolved":false,"context_lines":[{"line_number":299,"context_line":"        enc_val \u003d [enc_ctxt.update(chunk) for chunk in chunks]"},{"line_number":300,"context_line":"        self.assertTrue(\u0027\u0027.join(enc_val) !\u003d chunks)"},{"line_number":301,"context_line":""},{"line_number":302,"context_line":"        # Simulate a ranged GET from byte 4 to 12 : \u0027456789abc\u0027"},{"line_number":303,"context_line":"        dec_ctxt \u003d self.crypto.create_decryption_ctxt(key, iv, 4)"},{"line_number":304,"context_line":"        ranged_chunks \u003d [enc_val[0][4:], enc_val[1], enc_val[2][:3]]"},{"line_number":305,"context_line":"        dec_val \u003d [dec_ctxt.update(chunk) for chunk in ranged_chunks]"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_ef6112d5","line":302,"in_reply_to":"7aa08908_588e3928","updated":"2016-06-09 21:39:18.000000000","message":"Mahati: I re-read your comment.  Sorry I didn\u0027t simply answer your question.  My first thought was to explain at a high level.\n\nBut I think your test (the one in the paste) just needs to change to have the offset passed to the context ctor be over 15.  It has to have the offset in the ctor be in a different block than the first.  What matters here is the first block that the context will decrypt.\n\nBTW - without the iv recalculation, test_decrypter.test_GET_multipart_ciphertext fails already will fail.","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":12279,"name":"Janie Richling","email":"jrichli@us.ibm.com","username":"jrichli"},"change_message_id":"6194967e3af132cc6a34d9430bdd9e4fe6ae42e2","unresolved":false,"context_lines":[{"line_number":299,"context_line":"        enc_val \u003d [enc_ctxt.update(chunk) for chunk in chunks]"},{"line_number":300,"context_line":"        self.assertTrue(\u0027\u0027.join(enc_val) !\u003d chunks)"},{"line_number":301,"context_line":""},{"line_number":302,"context_line":"        # Simulate a ranged GET from byte 4 to 12 : \u0027456789abc\u0027"},{"line_number":303,"context_line":"        dec_ctxt \u003d self.crypto.create_decryption_ctxt(key, iv, 4)"},{"line_number":304,"context_line":"        ranged_chunks \u003d [enc_val[0][4:], enc_val[1], enc_val[2][:3]]"},{"line_number":305,"context_line":"        dec_val \u003d [dec_ctxt.update(chunk) for chunk in ranged_chunks]"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_588e3928","line":302,"in_reply_to":"7aa08908_77ace935","updated":"2016-06-09 19:01:13.000000000","message":"This is related to how CTR mode works.\nThere is a counter - a part of the iv - that is incremented for each block.\nWhen decrypting a range where we need to start decrypting in the middle of a message/object body, this counter will be a different value because its in the middle of the message instead of the beginning.\n\nI am still reviewing all the lines in 79-81 myself to really know what those particular calculations are the correct ones.  I think understanding this also may require knowledge of what \u0027decrypter\u0027 and \u0027CryptoContext\u0027 support or how they treat what we are calling the \u0027iv\u0027 under the hood.\n\nI do find it strange that the \u0027cryptography\u0027 methods would not account for this in the CryptoContext when the offset is being supplied.\n\nAnyway, for example, Alistair mentioned this example mapping:\n\nmappings \u003d {2: \u00270000000010000000\u0027,\n              16: \u00270000000010000001\u0027,\n              19: \u00270000000010000001\u0027,\n              48: \u00270000000010000003\u0027,\n              1024: \u0027000000001000000p\u0027}\n\nso this represents a nonce of \u0027000000001\u0027 - which is why you see it as the beginning of all values there - and then the last part is the \u0027counter\u0027 that gets incremented when the block is incremented. (16 and 19 are in the same block, so the nonce concat with counter is the same \u0027iv\u0027 value.)\n\nThe problem is that it has been difficult for me to determine exactly how the cryptography library is applying our given \u0027iv\u0027 - which they call \u0027nonce\u0027, but they force the value to be the whole block size (strictly speaking, the nonce is smaller than the block size).  I think we would need to verify that they are using the typical nonce concat with counter that we are familiar with.  If they are, then our counter is not starting at zero at the beginning, because we are not choosing our \u0027iv\u0027 in that way.\n\nI think there are other ways to take our given \u0027nounce\u0027 and make it different for each block. \n\nAnyway ... I will be doing some research into this.","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":12279,"name":"Janie Richling","email":"jrichli@us.ibm.com","username":"jrichli"},"change_message_id":"28a240340457aa3d6462df5d998be6fc4e69f43b","unresolved":false,"context_lines":[{"line_number":299,"context_line":"        enc_val \u003d [enc_ctxt.update(chunk) for chunk in chunks]"},{"line_number":300,"context_line":"        self.assertTrue(\u0027\u0027.join(enc_val) !\u003d chunks)"},{"line_number":301,"context_line":""},{"line_number":302,"context_line":"        # Simulate a ranged GET from byte 4 to 12 : \u0027456789abc\u0027"},{"line_number":303,"context_line":"        dec_ctxt \u003d self.crypto.create_decryption_ctxt(key, iv, 4)"},{"line_number":304,"context_line":"        ranged_chunks \u003d [enc_val[0][4:], enc_val[1], enc_val[2][:3]]"},{"line_number":305,"context_line":"        dec_val \u003d [dec_ctxt.update(chunk) for chunk in ranged_chunks]"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_d0e04ecf","line":302,"in_reply_to":"7aa08908_7e2ea4a5","updated":"2016-06-09 15:16:40.000000000","message":"This helps with what I was attempting to explain.  This is the test that I\u0027d modify to cover what is not for this non-zero case. And currently, the lines (that mahatic had linked to) are technically covered by this test case.  But now I understand the issue is not simply coverage, but wanting the lines to execute in such a way that an actual difference is made because that logic exists.  Thanks for the explanation, and I am on board.","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":12261,"name":"Mahati","email":"mahati.chamarthy@gmail.com","username":"Mahati"},"change_message_id":"63902734b63b9c78ff6a2c536c8d94d25d7aba55","unresolved":false,"context_lines":[{"line_number":299,"context_line":"        enc_val \u003d [enc_ctxt.update(chunk) for chunk in chunks]"},{"line_number":300,"context_line":"        self.assertTrue(\u0027\u0027.join(enc_val) !\u003d chunks)"},{"line_number":301,"context_line":""},{"line_number":302,"context_line":"        # Simulate a ranged GET from byte 4 to 12 : \u0027456789abc\u0027"},{"line_number":303,"context_line":"        dec_ctxt \u003d self.crypto.create_decryption_ctxt(key, iv, 4)"},{"line_number":304,"context_line":"        ranged_chunks \u003d [enc_val[0][4:], enc_val[1], enc_val[2][:3]]"},{"line_number":305,"context_line":"        dec_val \u003d [dec_ctxt.update(chunk) for chunk in ranged_chunks]"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_77ace935","line":302,"in_reply_to":"7aa08908_7e2ea4a5","updated":"2016-06-09 17:17:10.000000000","message":"pardon my ignorance. I don\u0027t fully understand the offset to iv mapping: even if I give two 16 byte ranges and try to encrypt a range spanning them, I thought I\u0027d still need to supply a correct offset, i.e, from which byte I need my data (range per se). For instance: http://paste.openstack.org/show/509280/\nThat also does not seem to require the iv recalculation.\n\nPointers for me to understand?","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"39f8738e2c822647f7af7fec5234100c848c8a4a","unresolved":false,"context_lines":[{"line_number":307,"context_line":"                         \u0027Expected value {%s} but got {%s}\u0027 %"},{"line_number":308,"context_line":"                         (\u0027456789abc\u0027, \u0027\u0027.join(dec_val)))"},{"line_number":309,"context_line":""},{"line_number":310,"context_line":"    def test_create_decryption_context_non_zero_offset(self):"},{"line_number":311,"context_line":"        iv \u003d self.crypto.create_iv()"},{"line_number":312,"context_line":"        offset \u003d [2, 16, 19, 48]"},{"line_number":313,"context_line":"        key \u003d \u0027objL7wjV6L79Sfs4y7dy41273l0k6Wki\u0027"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_3ea6dcad","line":310,"updated":"2016-06-09 09:17:45.000000000","message":"As it is the test basically duplicates the code under test. That is a form of defence against regression, but makes the test hard to understand on its own. The more I play with this the more I feel like it would we could have some expected mappings from offset to iv, given a zero-offset iv, for example something like:\n\n  iv \u003d \u00270000000010000000\u0027\n\n  mappings \u003d {2: \u00270000000010000000\u0027,\n              16: \u00270000000010000001\u0027,\n              19: \u00270000000010000001\u0027,\n              48: \u00270000000010000003\u0027,\n              1024: \u0027000000001000000p\u0027}\n\nIDK what should the mapping be for offset at 5GB -1 ?\n\n  for iv, offset in mappings:\n      self.assertEqual(iv, self.crypto.create_decryption_ctxt(key, iv, offset)","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":12261,"name":"Mahati","email":"mahati.chamarthy@gmail.com","username":"Mahati"},"change_message_id":"63902734b63b9c78ff6a2c536c8d94d25d7aba55","unresolved":false,"context_lines":[{"line_number":307,"context_line":"                         \u0027Expected value {%s} but got {%s}\u0027 %"},{"line_number":308,"context_line":"                         (\u0027456789abc\u0027, \u0027\u0027.join(dec_val)))"},{"line_number":309,"context_line":""},{"line_number":310,"context_line":"    def test_create_decryption_context_non_zero_offset(self):"},{"line_number":311,"context_line":"        iv \u003d self.crypto.create_iv()"},{"line_number":312,"context_line":"        offset \u003d [2, 16, 19, 48]"},{"line_number":313,"context_line":"        key \u003d \u0027objL7wjV6L79Sfs4y7dy41273l0k6Wki\u0027"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_970b552b","line":310,"in_reply_to":"7aa08908_3ea6dcad","updated":"2016-06-09 17:17:10.000000000","message":"I tried to use a binary converter to get the 5gb value, but obvisuoly I stopped because I don\u0027t fully understand the offset, iv mappings :) (related question above)","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":12279,"name":"Janie Richling","email":"jrichli@us.ibm.com","username":"jrichli"},"change_message_id":"83da6887f635760c1a92cefeab1f9095fed4ec8a","unresolved":false,"context_lines":[{"line_number":307,"context_line":"                         \u0027Expected value {%s} but got {%s}\u0027 %"},{"line_number":308,"context_line":"                         (\u0027456789abc\u0027, \u0027\u0027.join(dec_val)))"},{"line_number":309,"context_line":""},{"line_number":310,"context_line":"    def test_create_decryption_context_non_zero_offset(self):"},{"line_number":311,"context_line":"        iv \u003d self.crypto.create_iv()"},{"line_number":312,"context_line":"        offset \u003d [2, 16, 19, 48]"},{"line_number":313,"context_line":"        key \u003d \u0027objL7wjV6L79Sfs4y7dy41273l0k6Wki\u0027"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_14410a3a","line":310,"in_reply_to":"7aa08908_970b552b","updated":"2016-06-10 02:49:57.000000000","message":"I think what Alistair is saying is instead of asserting against a calculation of the iv within the test, just define a mapping (with a few entries) of offset to expected adjusted iv values.  then assert against that mapping.\n\nin general, the iv calculation computes (iv + offset) mod 2^128\n\nso ...\nfor an offest in block 1, we add nothing.\nfor an offset in block 2, we add one to the binary data.  In this case, the ascii value for 1 is one more than that for 0, so it looks like the addition is happening with the string representation.\nBut at some point, looking at the string representation doesn\u0027t help as much.\nIn order to figure out what value to put in the map for a given offset, just run the value through the method to see what iv it would give for that offset.  For example, 5GB leads to \u0027000000000000D000\u0027 and 5GB -1 leads to \u0027000000000000D00/\u0027.  So you could start with the map Alistair gave and add a couple more good cases.","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"39f8738e2c822647f7af7fec5234100c848c8a4a","unresolved":false,"context_lines":[{"line_number":316,"context_line":"            ivl \u003d long(binascii.hexlify(iv), 16)"},{"line_number":317,"context_line":"            ivl +\u003d int(val / 16) + (1 \u003c\u003c (16 * 8))"},{"line_number":318,"context_line":"            ivstr \u003d format(ivl, \u0027x\u0027)"},{"line_number":319,"context_line":"            iv \u003d str(bytearray.fromhex(ivstr[(len(ivstr) - 2 * 16):]))"},{"line_number":320,"context_line":"            self.assertEqual(iv, dec_ctxt.iv)"},{"line_number":321,"context_line":""},{"line_number":322,"context_line":"    def test_check_key(self):"}],"source_content_type":"text/x-python","patch_set":2,"id":"7aa08908_c31a5f7c","line":319,"updated":"2016-06-09 09:17:45.000000000","message":"reassigning iv here makes things interesting if you were trying to debug/fathom the test expectations.\n\nFor example, I printed the iv and expected to see the same iv value for offset 16 and 19, but didn\u0027t, because actually the zero-offset iv is changing for each iteration of the test.\n\nCould we change this iv variable to expected_iv?","commit_id":"9d598f6ee8ab40fe9a1ce2783a909465a5a9349a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"fe92d403b85c114926cfcfe49e5230ff581869a3","unresolved":false,"context_lines":[{"line_number":315,"context_line":"                    48: \u00270000000010000003\u0027,"},{"line_number":316,"context_line":"                    1024: \u0027000000001000000p\u0027,"},{"line_number":317,"context_line":"                    5119: \u0027000000001000001o\u0027}"},{"line_number":318,"context_line":"        for offset, exp_iv in mappings.iteritems():"},{"line_number":319,"context_line":"            dec_ctxt \u003d self.crypto.create_decryption_ctxt(key, iv, offset)"},{"line_number":320,"context_line":"            self.assertEqual(exp_iv, dec_ctxt.iv)"},{"line_number":321,"context_line":""}],"source_content_type":"text/x-python","patch_set":4,"id":"7aa08908_d4991bd2","line":318,"updated":"2016-06-16 16:19:39.000000000","message":"nit: use items(), iteritems() is not in py3 and it is a small dict","commit_id":"667a7027021ac5264794193fb83e9611dcff807b"}]}
