Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/04/05 09:45
Read: times


 
#94346 - platform-dependent
Responding to: ???'s previous message
Juan Carlos said:
Hi, I need to use the TEA Encryption method with uvision 3. The program works fine with other PC compilers, meaning that it enciphers and deciphers properly. I tried it with uvision 3, but it does not give the right result.

So, you're saying that whether it works or not is platform-dependent - therefore, you need to inspect the code for platform-dependencies

Dan Henry said:
TEA is sensitive to big-endian/little-endian differences. Take care of all endian-related issues. The PC and its compilers are little-endian. Keil's C51 toolchain is big-endian.

I don't know specifically about TEA, but "Endian-ness" is a prime suspect in any platform-dependence issue.
This will affect things like using unions and casting pointers to access individual bytes of larger objects.

Other general things to consider are:

  • Data sizes - a PC's int is probaly 32 bits; it's only 16 with Keil C51.
    To avoid such problems, never use the "raw" 'C' data types - always make your own typedefs to give you a known size & signedness; eg, U8, U16, S32.

  • Data alignment - a PC may well have issues about data alignment; eg, ints must start on an even address. This may cause the compiler to add "padding" in structures, etc.
    Keil C51 doesn't do this.

  • Default signed or unsigned? This may be an option in your compiler settings.

    Specifically for Keil C51, remember that "normal" 'C' functions are inherently reentrant, but C51 functions are not!

    Of course, you could also have plain simple bugs - your code only works on a PC by pure luck!


  • List of 30 messages in thread
    TopicAuthorDate
    TEA            01/01/70 00:00      
       Endianess            01/01/70 00:00      
          Any recommendations?            01/01/70 00:00      
             Assess your requirements            01/01/70 00:00      
             Test vectors            01/01/70 00:00      
          platform-dependent            01/01/70 00:00      
       Why TEA?            01/01/70 00:00      
          Did you Mean DES            01/01/70 00:00      
             Yes, DES            01/01/70 00:00      
                Here it is            01/01/70 00:00      
                   It would be better            01/01/70 00:00      
                      Go here!            01/01/70 00:00      
                   And what is your result?            01/01/70 00:00      
                      Not right?            01/01/70 00:00      
                         I expected that...            01/01/70 00:00      
                            Here are the results I am gettng            01/01/70 00:00      
                               Michael is right:            01/01/70 00:00      
                                  MS Visual C.            01/01/70 00:00      
                               Recipe for success            01/01/70 00:00      
                                  problem with "standard implementation"..            01/01/70 00:00      
                                     Example for the user            01/01/70 00:00      
                                        like this?            01/01/70 00:00      
                                           What else?            01/01/70 00:00      
                                              ???            01/01/70 00:00      
                                                 I noticed that            01/01/70 00:00      
                                           Statics init to zero            01/01/70 00:00      
                   Code Problems            01/01/70 00:00      
       Didn't search first?            01/01/70 00:00      
       It's easy?            01/01/70 00:00      
          Useful fast shift and roll functions            01/01/70 00:00      

    Back to Subject List