From 758687451009042d14fdf9cbced4afcabe3eece7 Mon Sep 17 00:00:00 2001 From: Sammy Pfeiffer Date: Sun, 15 Mar 2015 02:55:59 +0100 Subject: [PATCH] Added author name and some extra info --- encrypt_decrypt_ige_test.py | 6 ++++-- ige.py | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/encrypt_decrypt_ige_test.py b/encrypt_decrypt_ige_test.py index 97b870a5..d39a9ced 100644 --- a/encrypt_decrypt_ige_test.py +++ b/encrypt_decrypt_ige_test.py @@ -1,5 +1,7 @@ -__author__ = 'sam' - +# Author: Sammy Pfeiffer +# This file tests the AES 256 IGE cipher +# working in Python 2.7 and Python 3.4 (other versions untested) +# as it's needed for the implementation of Telegram API from ige import ige # AES 256 IGE is using AES ECB internally, it implies (extract from PyCrypto.cipher.AES): diff --git a/ige.py b/ige.py index 654f4ea5..1f21985a 100644 --- a/ige.py +++ b/ige.py @@ -1,12 +1,11 @@ # -*- coding: utf-8 -*- -# THIS MODULE HAS ALL THE CONVERSIONS WE NEED! (I think) +# Author: Sammy Pfeiffer +# This file implements the AES 256 IGE cipher +# working in Python 2.7 and Python 3.4 (other versions untested) +# as it's needed for the implementation of Telegram API +# It's based on PyCryto from __future__ import print_function from Crypto.Util import number -# trying to convert "automatically" input... -# tobytes() didnt work -# bstr() didnt work -# b() didnt work -# bord() didnt work (TypeError) from Crypto.Cipher import AES from sys import version_info if version_info >= (3, 4, 0): @@ -123,6 +122,7 @@ def ige(message, key, iv, operation="decrypt"): if __name__ == "__main__": + # Example data from https://core.telegram.org/mtproto/samples-auth_key#conversion-of-encrypted-answer-into-answer encrypted_answer_str = "28A92FE20173B347A8BB324B5FAB2667C9A8BBCE6468D5B509A4CBDDC186240AC912CF7006AF8926DE606A2E74C0493CAA57741E6C82451F54D3E068F5CCC49B4444124B9666FFB405AAB564A3D01E67F6E912867C8D20D9882707DC330B17B4E0DD57CB53BFAAFA9EF5BE76AE6C1B9B6C51E2D6502A47C883095C46C81E3BE25F62427B585488BB3BF239213BF48EB8FE34C9A026CC8413934043974DB03556633038392CECB51F94824E140B98637730A4BE79A8F9DAFA39BAE81E1095849EA4C83467C92A3A17D997817C8A7AC61C3FF414DA37B7D66E949C0AEC858F048224210FCC61F11C3A910B431CCBD104CCCC8DC6D29D4A5D133BE639A4C32BBFF153E63ACA3AC52F2E4709B8AE01844B142C1EE89D075D64F69A399FEB04E656FE3675A6F8F412078F3D0B58DA15311C1A9F8E53B3CD6BB5572C294904B726D0BE337E2E21977DA26DD6E33270251C2CA29DFCC70227F0755F84CFDA9AC4B8DD5F84F1D1EB36BA45CDDC70444D8C213E4BD8F63B8AB95A2D0B4180DC91283DC063ACFB92D6A4E407CDE7C8C69689F77A007441D4A6A8384B666502D9B77FC68B5B43CC607E60A146223E110FCB43BC3C942EF981930CDC4A1D310C0B64D5E55D308D863251AB90502C3E46CC599E886A927CDA963B9EB16CE62603B68529EE98F9F5206419E03FB458EC4BD9454AA8F6BA777573CC54B328895B1DF25EAD9FB4CD5198EE022B2B81F388D281D5E5BC580107CA01A50665C32B552715F335FD76264FAD00DDD5AE45B94832AC79CE7C511D194BC42B70EFA850BB15C2012C5215CABFE97CE66B8D8734D0EE759A638AF013" tmp_aes_key_str = "F011280887C7BB01DF0FC4E17830E0B91FBB8BE4B2267CB985AE25F33B527253" tmp_aes_iv_str = "3212D579EE35452ED23E0D0C92841AA7D31B2E9BDEF2151E80D15860311C85DB"