×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    29

    AES encryption plugin 1.0

    Hello,

    with the help from this forum, I finally managed to compile the AES module from the Python Cryptographic Toolkit. You can download it here (3rd Edition). It is WAY faster than any pure python implementation. It comes without any warranty whatsoever. If you find any bugs, please post them below.

    How to use:

    Code:
    import aes
    your_key = "yourpassphrase12" # must be 16, 32 or 64 bytes long
    
    t = aes.new(your_key, aes.MODE_CFB) #stream cipher
    enc = t.encrypt("data you want to encrypt")
    print t.decrypt(enc)
    edit: bug in the example code... the code above won't work. The t.decrypt(enc) will fail, because it does not have the correct initialisation vector. In order to fix it, just create a new aes object and use it to decrypt the encoded text.
    Last edited by quickie; 2007-04-24 at 13:01.

  2. #2
    Super Contributor
    Join Date
    May 2006
    Location
    Oulu, Finland
    Posts
    622

    Re: AES encryption plugin 1.0

    Excellent quickie

    2 things:
    I can't download the zip, please check the URL. I can ping haftbar.de but can't connect.
    Could you share also a build for 2nd edition?

    regards,

    LFD
    Devices:
    Nokia E61 3rd Edition - pys60 1.4.0

    Tips and modules:
    http://www.lfdm.net/thesis

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    29

    Re: AES encryption plugin 1.0

    The link should work now

    I don't have a 2nd edition sdk installed, so i can't compile it. I will post the sources next week, feel free to compile them yourself

    cheers,

    flo

  4. #4
    Super Contributor
    Join Date
    May 2006
    Location
    Oulu, Finland
    Posts
    622

    Re: AES encryption plugin 1.0

    Yes it works

    I'm looking forward to see the source!

    Could you package an unsigned version for developer certificates?

    I'll try to compile it also for 2nd edition.

    Thanks

    LFD
    Devices:
    Nokia E61 3rd Edition - pys60 1.4.0

    Tips and modules:
    http://www.lfdm.net/thesis

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    29

    Re: AES encryption plugin 1.0

    Hi,

    i just updated the aes.zip file. It now includes an unsigned version and the sources. I guess they'll need some cleanup

    cheers,
    flo

  6. #6
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: AES encryption plugin 1.0

    Quote Originally Posted by quickie
    Hi,

    i just updated the aes.zip file. It now includes an unsigned version and the sources. I guess they'll need some cleanup

    cheers,
    flo
    Thank you very much

    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  7. #7
    Regular Contributor
    Join Date
    Jan 2006
    Location
    CPH, Denmark
    Posts
    64

    Re: AES encryption plugin 1.0

    Nice! Good work - A C++ version of AES was needed

  8. #8
    Registered User
    Join Date
    Apr 2007
    Posts
    2

    Re: AES encryption plugin 1.0

    Does this support unicode at all?

    I'm getting an error when I try to encrypt a word with special letters, in this case letter 'Ä'.

    Code:
    File "e:\python\kassakaappi.py", line 16, in ?
    crypted_data = u.encrypt(data)
    UnicodeError: ASCII encoding error: ordinal not in range(128)
    And here's my code

    Code:
    import aes
    import appuifw
    
    fh = open ('e:\\test.txt', 'r')
    crypted_data = fh.read()
    fh.close()
    key = appuifw.query(u"Type your password:", "code")
    if len(key) < 32:
    	for x in range(32-len(key)):
    		key += u"0"
    t = aes.new(key, aes.MODE_CFB)
    data = t.decrypt(crypted_data)
    appuifw.note(u"The typed word was: " + data, "info")
    u = aes.new(key, aes.MODE_CFB)
    data = appuifw.query(u"Type a word:", "text")
    crypted_data = u.encrypt(data)
    fh = open ('e:\\test.txt', 'w+')
    fh.write(crypted_data)
    fh.close()

  9. #9
    Registered User
    Join Date
    Mar 2007
    Posts
    29

    Re: AES encryption plugin 1.0

    Hi,

    thanks for trying the AES plugin. You can't encode unicode strings directly.

    Try:
    Code:
    text = u"äöüß1234567890"
    encoded_text = text.encode("utf-8")
    You can now encrypt the encoded_text string. To encode it back to unicode try:

    Code:
    text_unicode = unicode(encoded_text,"utf-8")
    cheers,

    flo

  10. #10
    Registered User
    Join Date
    Apr 2007
    Posts
    2

    Re: AES encryption plugin 1.0

    Thanks for your quick reply, now my script works fine.

  11. #11
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: AES encryption plugin 1.0

    Quote Originally Posted by quickie View Post
    With the help from this forum, I finally managed to compile the AES module from the Python Cryptographic Toolkit. You can download it here (3rd Edition).
    Has anybody used this module successfully in PyS60 1.4.x?

    In above aes.zip: selfsigned (aes.sisx?) package is expired.

    If I sign unsigned version (aes.SIS?) with my devcert and include all 13 capabilities, my script shell complains after "import aes":
    ImportError: Permission denied (error -46). Possible cause: Check that aes.pyd is compiled to have at least the same capabilities as this Python interpreter process.
    Script shell is also signed with all 13 caps.

    If I try to compile it by my self, I'm getting this error: ..//..//9.1//S60_3rd_MR//EPOC32//include/e32def.h:2769: error: initializer element is not constant.
    Full work flow follows:

    1. Download and unzip aes.zip: http://haftbar.de/~lutz/aes.zip
    2. Open cmd.exe and cd to the source directory (e.g. C:\Symbian\aes\src). Then execute:
    3. bldmake bldfiles
    4. abld build gcce urel
      Above fails, here are the last lines:
      Code:
      make -s  -r -f "\Symbian\9.1\S60_3rd_MR\EPOC32\BUILD\Symbian\aes\src\AES\GCCE\AES.GCCE" UREL
      Aes.c
      cc1.exe: warning: command line option "-Wno-ctor-dtor-privacy" is valid for C++/ObjC++ but not for C
      In file included from ..//..//9.1//S60_3rd_MR//EPOC32//include//python/longobject.h:21,
                       from ..//..//9.1//S60_3rd_MR//EPOC32//include//python/Python.h:74,
                       from .\\Aes.c:32:
      ..//..//9.1//S60_3rd_MR//EPOC32//include/e32def.h:2769: error: initializer element is not constant
      make[1]: *** [..\..\9.1\S60_3rd_MR\EPOC32\BUILD\Symbian\aes\src\AES\GCCE\UREL\aes.o] Error 1
      make: *** [TARGETAES] Error 2
        make -r  -f "\Symbian\9.1\S60_3rd_MR\EPOC32\BUILD\Symbian\aes\src\GCCE.make" FINAL CFG=UREL VERBOSE=-s


    Line 2769 in EPOC32//include/e32def.h is this:
    Code:
    static const char* const KSuppressPlatSecDiagnostic = KSuppressPlatSecDiagnosticMagicValue;
    Is this some easy-to-fix known issue which occurs in Pys60 1.4.0 and newer? Perhaps some slight modification in .pkg or .mmp file is enough?

  12. #12
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: AES encryption plugin 1.0

    @aaapo:

    I have no problem with compilation of this package

    I have repacked signed and unsigned version

    You can download below.

    aes 1.0.0 3rd selfsigned
    aes 1.0.0 3rd unsigned (sign it with your dev cert BEFORE installing !)

    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  13. #13
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: AES encryption plugin 1.0

    Quote Originally Posted by cyke64 View Post
    I have no problem with compilation of this package
    I have repacked signed and unsigned version. aes 1.0.0 3rd unsigned (sign it with your dev cert BEFORE installing
    Okay and thank you, this one installed cleanly after signing and removal of old non-working installation.

    Could you please share which steps you had to make before successful compilation?

    At least in aes.pkg
    "_build\aes.pyd"-"c:\sys\bin\aes.pyd" ->
    "_build\aes.pyd"-"!:\sys\bin\aes.pyd"
    because package was installable both C- and E-drives?

  14. #14
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: AES encryption plugin 1.0

    Quote Originally Posted by aaaaapo View Post
    Has anybody used this module successfully in PyS60 1.4.x?

    In above aes.zip: selfsigned (aes.sisx?) package is expired.

    If I sign unsigned version (aes.SIS?) with my devcert and include all 13 capabilities, my script shell complains after "import aes":

    Script shell is also signed with all 13 caps.

    If I try to compile it by my self, I'm getting this error: ..//..//9.1//S60_3rd_MR//EPOC32//include/e32def.h:2769: error: initializer element is not constant.
    Full work flow follows:

    1. Download and unzip aes.zip: http://haftbar.de/~lutz/aes.zip
    2. Open cmd.exe and cd to the source directory (e.g. C:\Symbian\aes\src). Then execute:
    3. bldmake bldfiles
    4. abld build gcce urel
      Above fails, here are the last lines:
      Code:
      make -s  -r -f "\Symbian\9.1\S60_3rd_MR\EPOC32\BUILD\Symbian\aes\src\AES\GCCE\AES.GCCE" UREL
      Aes.c
      cc1.exe: warning: command line option "-Wno-ctor-dtor-privacy" is valid for C++/ObjC++ but not for C
      In file included from ..//..//9.1//S60_3rd_MR//EPOC32//include//python/longobject.h:21,
                       from ..//..//9.1//S60_3rd_MR//EPOC32//include//python/Python.h:74,
                       from .\\Aes.c:32:
      ..//..//9.1//S60_3rd_MR//EPOC32//include/e32def.h:2769: error: initializer element is not constant
      make[1]: *** [..\..\9.1\S60_3rd_MR\EPOC32\BUILD\Symbian\aes\src\AES\GCCE\UREL\aes.o] Error 1
      make: *** [TARGETAES] Error 2
        make -r  -f "\Symbian\9.1\S60_3rd_MR\EPOC32\BUILD\Symbian\aes\src\GCCE.make" FINAL CFG=UREL VERBOSE=-s


    Line 2769 in EPOC32//include/e32def.h is this:
    Code:
    static const char* const KSuppressPlatSecDiagnostic = KSuppressPlatSecDiagnosticMagicValue;
    Is this some easy-to-fix known issue which occurs in Pys60 1.4.0 and newer? Perhaps some slight modification in .pkg or .mmp file is enough?
    Hello aaaapo ,

    All steps are correct but you forgot one thing
    Have you read the release note in PyS60 source code

    Look below
    Your error come from this forgotten thing diff !

    FIXING THE S60 3.0 HEADERS
    --------------------------

    There are some bugs in the shipped SDK headers. To fix these, you must
    apply the patch pys60-fix-3rded-sdk.diff. To do this, you will need
    the GNU patch utility.

    You can patch the headers by going to the \epoc32\include directory on
    your SDK drive and giving the command:

    patch -p1 < (path to the diff file)\pys60-fix-3rded-sdk.diff

    You need to do this only once.


    Happy porting !

    BR
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  15. #15
    Registered User
    Join Date
    Mar 2008
    Posts
    49

    Re: AES encryption plugin 1.0

    Thanks!!! You've done a wonderfull job, just what I need!

    Hi, Mapick

Similar Threads

  1. Replies: 2
    Last Post: 2008-04-03, 19:02
  2. HELP! OMA 1.0 SD encryption
    By tabstop in forum Digital Rights Management & Content Downloading
    Replies: 3
    Last Post: 2006-09-12, 09:29
  3. Nokia手机主要参数列表
    By cqucyf in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 0
    Last Post: 2005-05-04, 16:34
  4. Wallet 1.0 encryption & backup
    By dantams in forum General Development Questions
    Replies: 0
    Last Post: 2005-01-28, 09:30
  5. S90 MIDP SDK 1.0 Beta MMAPI Problem
    By kfalck in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2004-06-21, 19:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×