)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":6488,"name":"Clint Byrum","email":"clint@fewbar.com","username":"clint-fewbar"},"change_message_id":"bb2dd7b2c01ce34ec39062ca443405579426ec17","unresolved":false,"context_lines":[{"line_number":5,"context_line":"CommitDate: 2013-12-06 12:00:43 +1100"},{"line_number":6,"context_line":""},{"line_number":7,"context_line":"oslo: add crypto"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Change-Id: I622b9d0c942075f99fdbaff470906123c631504a"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":5,"id":"AAAATn%2F9soo%3D","line":8,"updated":"2013-12-07 02:57:05.000000000","message":"nit pick: why do we need crypto?","commit_id":"b2a1242cb10ffc7a94bcb91397159d3833048865"}],"heat/openstack/common/crypto/utils.py":[{"author":{"_account_id":6456,"name":"Sahdev Zala","email":"spzala@us.ibm.com","username":"spzala"},"change_message_id":"5daa3bfe0c3bf23dca9f07c47d7756c97e5a855b","unresolved":false,"context_lines":[{"line_number":124,"context_line":"        :param key: The Encryption key."},{"line_number":125,"context_line":"        :param msg: the plain text."},{"line_number":126,"context_line":""},{"line_number":127,"context_line":"        :returns encblock: a block of encrypted data."},{"line_number":128,"context_line":"        \"\"\""},{"line_number":129,"context_line":"        iv \u003d Random.new().read(self.cipher.block_size)"},{"line_number":130,"context_line":"        cipher \u003d self.cipher.new(key, self.cipher.MODE_CBC, iv)"}],"source_content_type":"text/x-python","patch_set":6,"id":"AAAATn%2F9qxI%3D","line":127,"updated":"2013-12-09 01:29:21.000000000","message":"Awesome. Just couple nits - one here and one below, \n\nThe return parameter is \"enc\" not \"encblock\"","commit_id":"4dbb71e4de1b4633dbf446822cfa0e607b5324dc"},{"author":{"_account_id":6456,"name":"Sahdev Zala","email":"spzala@us.ibm.com","username":"spzala"},"change_message_id":"5daa3bfe0c3bf23dca9f07c47d7756c97e5a855b","unresolved":false,"context_lines":[{"line_number":144,"context_line":"        return enc"},{"line_number":145,"context_line":""},{"line_number":146,"context_line":"    def decrypt(self, key, msg, b64decode\u003dTrue):"},{"line_number":147,"context_line":"        \"\"\"Decrypts the provided ciphertext, optionally base 64 encoded, and"},{"line_number":148,"context_line":"        returns the plaintext message, after padding is removed."},{"line_number":149,"context_line":""},{"line_number":150,"context_line":"        Uses AES-128-CBC with an IV by default."}],"source_content_type":"text/x-python","patch_set":6,"id":"AAAATn%2F9qxQ%3D","line":147,"updated":"2013-12-09 01:29:21.000000000","message":"base64  (vs base 64)","commit_id":"4dbb71e4de1b4633dbf446822cfa0e607b5324dc"},{"author":{"_account_id":8590,"name":"Jeffrey Walton","email":"noloader@gmail.com","username":"noloader"},"change_message_id":"d66421835bfb46b21ea108a6a3ccf11156704b09","unresolved":false,"context_lines":[{"line_number":44,"context_line":"        message \u003d msg % {\u0027given\u0027: requested, \u0027maximum\u0027: permitted}"},{"line_number":45,"context_line":"        super(CryptoutilsException, self).__init__(message)"},{"line_number":46,"context_line":""},{"line_number":47,"context_line":""},{"line_number":48,"context_line":"class HKDF(object):"},{"line_number":49,"context_line":"    \"\"\"An HMAC-based Key Derivation Function implementation (RFC5869)"},{"line_number":50,"context_line":""}],"source_content_type":"text/x-python","patch_set":8,"id":"AAAATn%2F8rJw%3D","line":47,"updated":"2013-12-23 12:44:02.000000000","message":"This HKDF might be OK, but its usage is probably wrong. If a caller passes the same initial key material (IKM) to this function, then the function will always return the same key material.\n\nThe implications are: the same IKM leads to the same key for encryption and signing. This is bad because there is no key independence.\n\nThe IKM also derives to the same key, even with V1 and V2 of the algorithm. WInzip suffers this attack between V1 and V2 of its encryption algorithm (https://homes.cs.washington.edu/~yoshi/papers/WinZip/winzip.pdf?).\n\nSuggested fixes:\n\n(1) Have the HKDF accept a \"usage\" label or string - this will ensure different usage of the same key material results in different derived keys. Provide a default usage label for those who don\u0027t appreciate the finer points of key derivation.\n\n(2) Have the HKDF accept a \"version\" label or string - this will ensure different versions of the algorithm or object derive to different keys. Provide a default version label for those who don\u0027t appreciate the finer points of key derivation.\n\n(3) Have the HKDF accept a \"component\" label or string - this will ensure different components derive different keys under the same IKM. Provide a default component label for those who don\u0027t appreciate the finer points of key derivation.\n\nThe idea is that the HKDF, the encrypt routing, and the sign routine to attempt to use as much context dependent information as possible to ensure unique derivations, even when subject to the same initial keying material.","commit_id":"37919c6b955e9f9b87d4dc76056efce858c63b1d"},{"author":{"_account_id":8590,"name":"Jeffrey Walton","email":"noloader@gmail.com","username":"noloader"},"change_message_id":"d66421835bfb46b21ea108a6a3ccf11156704b09","unresolved":false,"context_lines":[{"line_number":93,"context_line":""},{"line_number":94,"context_line":"MAX_CB_SIZE \u003d 256"},{"line_number":95,"context_line":""},{"line_number":96,"context_line":""},{"line_number":97,"context_line":"class SymmetricCrypto(object):"},{"line_number":98,"context_line":"    \"\"\"Symmetric Key Crypto object."},{"line_number":99,"context_line":""}],"source_content_type":"text/x-python","patch_set":8,"id":"AAAATn%2F8rBw%3D","line":96,"updated":"2013-12-23 12:44:02.000000000","message":"SymmetricCrypto provides two primitives - encrypt and sign. However, it should also provide an authenticated encryption function since its rarely acceptable to allow cipher text to be manipulated. CBC mode can be manipulated - see, for example, Practical malleability attack against CBC-Encrypted LUKS partitions, http://www.jakoblell.com/blog/2013/12/22/practical-malleability-attack-against-cbc-encrypted-luks-partitions/.\n\nThe authenticated encryption scheme should use a mode like OCB, EAX, or GCM. In the absence of the dedicated mode, there should be an Encrypt-then-Authenticate scheme available so developers don\u0027t have to [possibly incorrectly] roll their own.","commit_id":"37919c6b955e9f9b87d4dc76056efce858c63b1d"},{"author":{"_account_id":8590,"name":"Jeffrey Walton","email":"noloader@gmail.com","username":"noloader"},"change_message_id":"d66421835bfb46b21ea108a6a3ccf11156704b09","unresolved":false,"context_lines":[{"line_number":107,"context_line":"    def __init__(self, enctype\u003d\u0027AES\u0027, hashtype\u003d\u0027SHA256\u0027):"},{"line_number":108,"context_line":"        self.cipher \u003d importutils.import_module(\u0027Crypto.Cipher.\u0027 + enctype)"},{"line_number":109,"context_line":"        self.hashfn \u003d importutils.import_module(\u0027Crypto.Hash.\u0027 + hashtype)"},{"line_number":110,"context_line":""},{"line_number":111,"context_line":"    def new_key(self, size):"},{"line_number":112,"context_line":"        return Random.new().read(size)"},{"line_number":113,"context_line":""}],"source_content_type":"text/x-python","patch_set":8,"id":"AAAATn%2F8rJE%3D","line":110,"updated":"2013-12-23 12:44:02.000000000","message":"Can anyone confirm Random.new() is providing a secure generator? I seem to recall Pycypto had some problems in the past with its generator. Is it not possible to simply read from /dev/{u}random?","commit_id":"37919c6b955e9f9b87d4dc76056efce858c63b1d"},{"author":{"_account_id":8590,"name":"Jeffrey Walton","email":"noloader@gmail.com","username":"noloader"},"change_message_id":"d66421835bfb46b21ea108a6a3ccf11156704b09","unresolved":false,"context_lines":[{"line_number":110,"context_line":""},{"line_number":111,"context_line":"    def new_key(self, size):"},{"line_number":112,"context_line":"        return Random.new().read(size)"},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"    def encrypt(self, key, msg, b64encode\u003dTrue):"},{"line_number":115,"context_line":"        \"\"\"Encrypt the provided msg and returns the cyphertext optionally"},{"line_number":116,"context_line":"        base64 encoded."}],"source_content_type":"text/x-python","patch_set":8,"id":"AAAATn%2F8rHU%3D","line":113,"updated":"2013-12-23 12:44:02.000000000","message":"See the comment on the HKDF deriving the same key. Here, the \u0027encrypt\u0027 function should take the key, and further derive another key to ensure uniqueness. It can be as simple as:\n\nenc_key \u003d HKDF(key, \"encryption, \"1\"), then use enc_key as the encryption key.\n\nIn the above, \"encryption\" is a usage label and ensures derivation to a unique key that won\u0027t collide with keys for other usage, such as signing. The \"1\" label is version info and ensures different versions produce different keys.\n\nThere\u0027s ways to make it even better, but they are a little more complicated. For example, the label could include components like \"Component A\" or \"Component A:Component B\" so that derivation for a particular component or  between components is different among components.","commit_id":"37919c6b955e9f9b87d4dc76056efce858c63b1d"},{"author":{"_account_id":8590,"name":"Jeffrey Walton","email":"noloader@gmail.com","username":"noloader"},"change_message_id":"d66421835bfb46b21ea108a6a3ccf11156704b09","unresolved":false,"context_lines":[{"line_number":125,"context_line":"        :param msg: the plain text."},{"line_number":126,"context_line":""},{"line_number":127,"context_line":"        :returns encblock: a block of encrypted data."},{"line_number":128,"context_line":"        \"\"\""},{"line_number":129,"context_line":"        iv \u003d Random.new().read(self.cipher.block_size)"},{"line_number":130,"context_line":"        cipher \u003d self.cipher.new(key, self.cipher.MODE_CBC, iv)"},{"line_number":131,"context_line":""}],"source_content_type":"text/x-python","patch_set":8,"id":"AAAATn%2F8rMg%3D","line":128,"updated":"2013-12-23 12:44:02.000000000","message":"Can anyone confirm Random.new() is providing a secure generator? I seem to recall Pycypto had some problems in the past with its generator. Is it not possible to simply read from /dev/{u}random?","commit_id":"37919c6b955e9f9b87d4dc76056efce858c63b1d"},{"author":{"_account_id":8590,"name":"Jeffrey Walton","email":"noloader@gmail.com","username":"noloader"},"change_message_id":"d66421835bfb46b21ea108a6a3ccf11156704b09","unresolved":false,"context_lines":[{"line_number":133,"context_line":"        # padding."},{"line_number":134,"context_line":"        if self.cipher.block_size \u003e MAX_CB_SIZE:"},{"line_number":135,"context_line":"            raise CipherBlockLengthTooBig(self.cipher.block_size, MAX_CB_SIZE)"},{"line_number":136,"context_line":"        r \u003d len(msg) % self.cipher.block_size"},{"line_number":137,"context_line":"        padlen \u003d self.cipher.block_size - r - 1"},{"line_number":138,"context_line":"        msg +\u003d \u0027\\x00\u0027 * padlen"},{"line_number":139,"context_line":"        msg +\u003d chr(padlen)"}],"source_content_type":"text/x-python","patch_set":8,"id":"AAAATn%2F8rMw%3D","line":136,"updated":"2013-12-23 12:44:02.000000000","message":"This does not look right (please forgive me if I am mistaken). If one pad byte is required, a single 0x01 is added as padding. If two pad bytes are required, then two 0x02 bytes ({0x02,0x02}) are added. If three pad bytes are required, then three 0x03 bytes ({0x03,0x03,0x03}) are added. And so on.\n\nThe problem appear to be when the plain text is a multiple of block size. In this case, 16 each bytes of 0x16 ({0x16, \u003crepeat 14 time\u003e, 0x16}) should be added. But it appears 15 bytes might be added. For example, let:\n\n    msg \u003d \"AAAAAAAAAAAAAAAA\"\n    16 \u003d len(msg)\n\n    r \u003d len(msg) % self.cipher.block_size\n    r \u003d 16 % 16 \u003d 0\n\n    padlen \u003d self.cipher.block_size - r - 1\n    padlen \u003d 16 - 0 - 1 \u003d 15","commit_id":"37919c6b955e9f9b87d4dc76056efce858c63b1d"},{"author":{"_account_id":8590,"name":"Jeffrey Walton","email":"noloader@gmail.com","username":"noloader"},"change_message_id":"d66421835bfb46b21ea108a6a3ccf11156704b09","unresolved":false,"context_lines":[{"line_number":161,"context_line":"        l \u003d ord(padded[-1]) + 1"},{"line_number":162,"context_line":"        plain \u003d padded[:-l]"},{"line_number":163,"context_line":"        return plain"},{"line_number":164,"context_line":""},{"line_number":165,"context_line":"    def sign(self, key, msg, b64encode\u003dTrue):"},{"line_number":166,"context_line":"        \"\"\"Signs a message string and returns a base64 encoded signature."},{"line_number":167,"context_line":""}],"source_content_type":"text/x-python","patch_set":8,"id":"AAAATn%2F8rG8%3D","line":164,"updated":"2013-12-23 12:44:02.000000000","message":"See the comment on the HKDF deriving the same key. Here, the \u0027sign\u0027 function should take the key, and further derive another key to ensure uniqueness. It can be as simple as:\n\nauth_key \u003d HKDF(key, \"authentication, \"1\"), then use auth_key as the signing key.\n\nIn the above, \"authentication\" is a usage label and ensures derivation to a unique key that won\u0027t collide with keys for other usage, such as signing. The \"1\" label is version info and ensures different versions produce different keys.\n\nThere\u0027s ways to make it even better, but they are a little more complicated. For example, the label could include components like \"Component A\" or \"Component A:Component B\" so that derivation for a particular component or  between components is different among components.","commit_id":"37919c6b955e9f9b87d4dc76056efce858c63b1d"}]}
