xtea encryption


Closed Thread
Results 1 to 10 of 10

Thread: xtea encryption

  1. #1
    toalan's Avatar
    toalan Guest

    Default xtea encryption

    I just implemented xtea for the AVR MCU using C, it might be hard to implement in Picbasic since 32 bit unsigned long integers are not supported (I think).

    I just copied from http://www.answers.com/topic/xtea into my C compiler (IAR embedded workbench)and was able to use it without modification for AVR.

    xtea is supposed to be one of the most secure ( I do not think it has been cracked yet) and fastest algorithims. I looked into DES and AES and they seemed to time consuming to implement. I think xtea or one of its variants is used for the xbox.

    I am using xtea to encrypt firmware so people can flash upgrade stuff without me worrying that they will steal my work.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by toalan
    xtea is supposed to be one of the most secure ( I do not think it has been cracked yet)
    LMAO well since you have a code and the explanation can be found somewhere... what is the big deal to crack something with it???

    BTW all alrgorithm are still human made... another can bypass it easy... really easy

    Quote Originally Posted by toalan
    I think xtea or one of its variants is used for the xbox.
    no comments, some are in jail now...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    toalan's Avatar
    toalan Guest


    Did you find this post helpful? Yes | No

    Default

    Sorry I am not following you, my implementation is to supply people with encrypted firmware, they send it to the MCU and the MCU will decrypt the data and write it to flash memory.

    If you can bypass encryption easily then you are one of the few geniuses and perhaps your work has been undocumented. As of 2004 there is been no officially successful attempts at breaking the xtea algorithim.

    The xtea algorithim in xbox was never really borken, people exploited flaws in the hardware design to run unsigned code, most notably the big font flaw.

  4. #4
    toalan's Avatar
    toalan Guest


    Did you find this post helpful? Yes | No

    Default

    if you guys are interested in my XTEA bootloader here it is http://www.14point7.com/AVR.htm

  5. #5
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    I will need to use encryption in a wireless stream for an upcoming product. XTEA looks good, and compact. I will write in assembly, but I wondered if anyone has played with this in PBP? It looks like a fun excercise, especially with the version 2.5 longs! Any other ideas for good encryption without a lot of overhead? It needs to stand up to that .01% of attacks.
    Thanks,
    Ron

  6. #6
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    Go to the Swordfish Basic compiler site and download their demo program; it has XTEA with it. Surely you can convert it.
    http://www.sfcompiler.co.uk/swordfish/

  7. #7
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tenaja View Post
    Go to the Swordfish Basic compiler site and download their demo program; it has XTEA with it. Surely you can convert it.
    http://www.sfcompiler.co.uk/swordfish/
    I downloaded Swordfish, but cannot find any mention of TEA, XTEA, or TEA-N. Where did you find it?

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Should be in "\Sample\encryption" folder.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    OK, here it is. These subs will take an eight byte block of code, and encrypt it, then decrypt it. The key must be exactly the same for encrypt and decrypt, and don't mess with "Delta". This is only for the PIC18s and PBPL(2.50a)


    Code:
    ;**********************************************************************
    ; XTEA VARIABLES  *****************************************************
    ;**********************************************************************
    roundin     con     32            ;number of loops
    Delta       con    $9E3779B9       ;5/4/2 * 2power32
    
    round       var     byte
    Sumin       var     long
    vy          var     Long
    text_byte   var     byte[8]     ;text coming in, going out.
    vz          var     Long
    tb          var     byte
    Sum         var     long
    temp        var     long
    tmp0         var    temp.byte0
    tmp1         var    temp.byte1
    tmp2         var    temp.byte2
    tmp3         var    temp.byte3
    key         var     long[4]
    ka         var      key[0]
    
    kb         var     key[1]
    kc         var     key[2]
    kd         var     key[3]
    limit       var     long
    block       var     long[2]
    index       var     word
    key[0] =    $31323334        ;128 bit key
    key[1]  =   $93D8E9AF       ;don't use mine
    key[2]  =   $275FC2BA       ;must be
    key[3]  =   $95E20110       ;random
            
    
    ;**********************************************************************
    
    
    
    main:
               
               
                           
                hserout [str text_byte\8,13]    ;the unchanged block of 8 bytes
                  gosub beep   
                ;pause 1000
                   GOsub TEAenc                    ;scramble well
                hserout [str text_byte\8,13]    ;show mess
                 gosub teadec                       ;unscramble
                hserout [str text_byte\8,13]    ;No s--t, it works!
                   pause 100    
                 stop   
    TEAenc:     for tb = 0 to 3  ; convert string into code
                 vy.byte0[tb] = text_byte[tb]
                 vz.byte0[tb] = text_byte[tb+4] 
                 next tb                                                            
                sum = 0
                Limit = Delta * roundin 
                 while Sum <> limit
                 vy = vy + (((vz<<4) ^ (vz >>5))^(Sum + Key[sum & 3]))
                 sum = sum + Delta
                 vz = vz + (((vy<<4) ^ (vy >>5))^(Sum + Key[sum>>11 & 3]))
                    wend
                    for tb = 0 to 3
                   text_byte[tb]= vy.byte0[tb]
                   text_byte[tb+4] = vz.byte0[tb]
                 next tb
                   return 
              
    ;***************************************************************************            
    TEAdec:       ;Convert code into string
                for tb = 0 to 3
                 vy.byte0[tb] = text_byte[tb]
                 vz.byte0[tb] = text_byte[tb+4] 
                 next tb
                             
                       sum = Delta * roundin
                 while sum <> 0      
                   vz = vz - (((vy<<4) ^ (vy >>5))^(Sum + Key[(sum>>11) & 3]))
                    sum = sum - Delta
                   vy = vy - (((vz<<4) ^ (vz >>5))^(Sum + Key[sum & 3]))
                     wend
                     for tb = 0 to 3
                   text_byte[tb]= vy.byte0[tb]
                   text_byte[tb+4] = vz.byte0[tb]
                 next tb
                   return
    Last edited by Ron Marcus; - 2nd May 2008 at 18:52. Reason: added notation

  10. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Looks good to me at first glance. Sure some will use it.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. encryption ?
    By RAYMON in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 25th February 2009, 14:25
  2. XTEA Encrypt Decrypt Routines
    By Ron Marcus in forum Code Examples
    Replies: 0
    Last Post: - 3rd May 2008, 14:38
  3. AES Encryption on PIC16F/18F
    By Emerson in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 17th November 2005, 00:45
  4. Encryption in pics - why?
    By rastan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2005, 15:23
  5. TEA encryption and embedding in PBP
    By rastan in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 19th February 2005, 01:38

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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