I2C toy code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

92 line
3.3 KiB

  1. Tech Note 0006
  2. PK Standards Compliance
  3. Tom St Denis
  4. RSA
  5. ----
  6. PKCS #1 compliance.
  7. Key Format: RSAPublicKey and RSAPrivateKey as per PKCS #1 v2.1
  8. Encryption: OAEP as per PKCS #1
  9. Signature : PSS as per PKCS #1
  10. DSA
  11. ----
  12. The NIST DSA algorithm
  13. Key Format: HomeBrew [see below]
  14. Signature : ANSI X9.62 format [see below].
  15. Keys are stored as
  16. DSAPublicKey ::= SEQUENCE {
  17. publicFlags BIT STRING(1), -- must be 0
  18. g INTEGER , -- base generator, check that g^q mod p == 1
  19. -- and that 1 < g < p - 1
  20. p INTEGER , -- prime modulus
  21. q INTEGER , -- order of sub-group (must be prime)
  22. y INTEGER , -- public key, specifically, g^x mod p,
  23. -- check that y^q mod p == 1
  24. -- and that 1 < y < p - 1
  25. }
  26. DSAPrivateKey ::= SEQUENCE {
  27. publicFlags BIT STRING(1), -- must be 1
  28. g INTEGER , -- base generator, check that g^q mod p == 1
  29. -- and that 1 < g < p - 1
  30. p INTEGER , -- prime modulus
  31. q INTEGER , -- order of sub-group (must be prime)
  32. y INTEGER , -- public key, specifically, g^x mod p,
  33. -- check that y^q mod p == 1
  34. -- and that 1 < y < p - 1
  35. x INTEGER -- private key
  36. }
  37. Signatures are stored as
  38. DSASignature ::= SEQUENCE {
  39. r, s INTEGER -- signature parameters
  40. }
  41. ECC
  42. ----
  43. The ANSI X9.62 and X9.63 algorithms [partial]. Supports all NIST GF(p) curves.
  44. Key Format : Homebrew [see below, only GF(p) NIST curves supported]
  45. Signature : X9.62 compliant
  46. Encryption : Homebrew [based on X9.63, differs in that the public point is stored as an ECCPublicKey]
  47. Shared Secret: X9.63 compliant
  48. ECCPublicKey ::= SEQUENCE {
  49. flags BIT STRING(1), -- public/private flag (always zero),
  50. keySize INTEGER, -- Curve size (in bits) divided by eight
  51. -- and rounded down, e.g. 521 => 65
  52. pubkey.x INTEGER, -- The X co-ordinate of the public key point
  53. pubkey.y INTEGER, -- The Y co-ordinate of the public key point
  54. }
  55. ECCPrivateKey ::= SEQUENCE {
  56. flags BIT STRING(1), -- public/private flag (always one),
  57. keySize INTEGER, -- Curve size (in bits) divided by eight
  58. -- and rounded down, e.g. 521 => 65
  59. pubkey.x INTEGER, -- The X co-ordinate of the public key point
  60. pubkey.y INTEGER, -- The Y co-ordinate of the public key point
  61. secret.k INTEGER, -- The secret key scalar
  62. }
  63. The encryption works by finding the X9.63 shared secret and hashing it. The hash is then simply XOR'ed against the message [which must be at most the size
  64. of the hash digest]. The format of the encrypted text is as follows
  65. ECCEncrypted ::= SEQUENCE {
  66. hashOID OBJECT IDENTIFIER, -- The OID of the hash used
  67. pubkey OCTET STRING , -- Encapsulation of a random ECCPublicKey
  68. skey OCTET STRING -- The encrypted text (which the hash was XOR'ed against)
  69. }
  70. % $Source: /cvs/libtom/libtomcrypt/notes/tech0006.txt,v $
  71. % $Revision: 1.2 $
  72. % $Date: 2005/06/18 02:26:27 $