浏览代码

fix backwards compatibility for unencrypted repos

Thomas Waldmann 10 年之前
父节点
当前提交
c759eeee1e
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      attic/key.py

+ 6 - 3
attic/key.py

@@ -652,16 +652,19 @@ def legacy_parser(all_data, key_type):  # all rather hardcoded
     """
     """
     offset = 1
     offset = 1
     if key_type == PlaintextKey.TYPE:
     if key_type == PlaintextKey.TYPE:
+        mac_type = SHA256.TYPE
         mac = None
         mac = None
+        cipher_type = PLAIN.TYPE
         iv = None
         iv = None
         data = all_data[offset:]
         data = all_data[offset:]
     else:
     else:
+        mac_type = HMAC_SHA256.TYPE
         mac = all_data[offset:offset+32]
         mac = all_data[offset:offset+32]
+        cipher_type = AES_CTR_HMAC.TYPE
         iv = PREFIX + all_data[offset+32:offset+40]
         iv = PREFIX + all_data[offset+32:offset+40]
         data = all_data[offset+40:]
         data = all_data[offset+40:]
-    meta = Meta(compr_type=6, key_type=key_type,
-                mac_type=HMAC_SHA256.TYPE, cipher_type=AES_CTR_HMAC.TYPE,
-                iv=iv, legacy=True)
+    meta = Meta(compr_type=6, key_type=key_type, mac_type=mac_type,
+                cipher_type=cipher_type, iv=iv, legacy=True)
     return mac, meta, data
     return mac, meta, data
 
 
 def parser00(all_data):
 def parser00(all_data):