Javacard Cryptography: General Hints
Javacard Cryptography: General Hints
General hints:
• Use existing algorithms/modes rather than write your own - Algorithms in
JavaCard are much slower and most probably less secure against power analysis
than the native functions provided by JavaCard library.
• Store session data in RAM – operation in RAM are much faster and more secure
against power analysis. Moreover, EEPROM has limited number of rewrites before
becomes unreliable (105 - 106 writes).
• Do NOT store keys and PINs in primitive arrays – Use specialized objects like
OwnerPIN and Key for storage. These are better protected against power ad fault
attacks.
• Erase unused keys and arrays with sensitive values – Use specialized method if
exists (Key::clearKey()) or overwrite with random data.
• Use transactions to ensure atomic operations – Short parts of code that must be
executed together should be protected by the transaction. Otherwise, power supply
can be interrupted inside code and inconsistency may occur. Be aware of attacks
based on interrupted transactions so called Rollback attack.
• Do not use conditional jumps with sensitive data – Branching after condition is
recognizable with power analysis. E.g., branch THEN increase offset for next
instruction only by 1, but branch ELSE must compute new offset dependent on length
of THEN code. This addition takes much longer time and is recognizable using power
analysis.
• Allocate all necessary resources in constructor – Applet installation is usually
performed in trusted environment. Will prevent attacks based on limiting resources
necessary for applet and thus introducing inconsistency into applet execution.