home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / HPACK78S.ZIP / crypt / packet.h < prev    next >
Text File  |  1992-11-23  |  5KB  |  138 lines

  1. /****************************************************************************
  2. *                                                                            *
  3. *                            HPACK Multi-System Archiver                        *
  4. *                            ===========================                        *
  5. *                                                                            *
  6. *                        Encryption Packet Interface Header                        *
  7. *                            PACKET.H  Updated 12/07/92                        *
  8. *                                                                            *
  9. * This program is protected by copyright and as such any use or copying of    *
  10. *  this code for your own purposes directly or indirectly is highly uncool    *
  11. *                      and if you do so there will be....trubble.                *
  12. *                 And remember: We know where your kids go to school.            *
  13. *                                                                            *
  14. *        Copyright 1991 - 1992  Peter C.Gutmann.  All rights reserved        *
  15. *                                                                            *
  16. ****************************************************************************/
  17.  
  18. /* Note that the following packet definitions aren't compatible with PGP
  19.    packets since HPACK uses its own packet format.  Seperate packet
  20.    definitions for PGP are given below */
  21.  
  22. /* Cipher Type Byte (CTB) definitions */
  23.  
  24. #define CTB_BITS            0xA0    /* Magic bits to signify CTB */
  25. #define CTB_BIT_MASK        0xF0    /* Mask value for magic bits */
  26. #define CTB_MORE            0x08    /* Value for 'more' bitflag */
  27. #define CTB_MORE_MASK        0x08    /* Mask value for more bitflag */
  28. #define CTB_TYPE_MASK        0x07    /* Mask value for type field */
  29.  
  30. /* Defines to extract information from the CTB */
  31.  
  32. #define isCTB(ctb)            ( ( ( ctb ) & CTB_BIT_MASK ) == CTB_BITS )
  33. #define hasMore(ctb)        ( ( ctb ) & CTB_MORE_MASK )
  34. #define ctbType(ctb)        ( ( ctb ) & CTB_TYPE_MASK )
  35.  
  36. /* Magic values for the CTB as used by HPACK */
  37.  
  38. #define CTBTYPE_PKE            0    /* Packet encrypted with RSA public key */
  39. #define CTBTYPE_SKE            1    /* Packet signed with RSA secret key */
  40. #define CTBTYPE_MD            2    /* Message digest packet */
  41. #define CTBTYPE_MDINFO        3    /* Message digest information packet */
  42. #define CTBTYPE_CKE            4    /* Conventional-key-encryption packet */
  43. #define CTBTYPE_CKEINFO        5    /* Conventional-key-encryption info packet */
  44.  
  45. /* A set of mysterious defines to build up a CTB */
  46.  
  47. #define    makeCtb(type)        ( CTB_BITS | type )
  48.  
  49. #define CTB_PKE             makeCtb( CTBTYPE_PKE )
  50. #define CTB_SKE             makeCtb( CTBTYPE_SKE )
  51. #define CTB_MD                 makeCtb( CTBTYPE_MD )
  52. #define CTB_MDINFO            makeCtb( CTBTYPE_MDINFO )
  53. #define CTB_CKE                makeCtb( CTBTYPE_CKE )
  54. #define CTB_CKEINFO            makeCtb( CTBTYPE_CKEINFO )
  55.  
  56. /****************************************************************************
  57. *                                                                            *
  58. *                            PGP Packet Information                            *
  59. *                                                                            *
  60. ****************************************************************************/
  61.  
  62. /* PGP CTB length values */
  63.  
  64. #define ctbLength(ctb)        ( ( ctb ) & 3 )
  65.  
  66. enum { CTB_LEN_BYTE, CTB_LEN_WORD, CTB_LEN_LONG, CTB_LEN_NONE };
  67.  
  68. /* PGP CTB types */
  69.  
  70. #define CTBTYPE_CERT_SECKEY    0x95    /* Secret key certificate */
  71. #define CTBTYPE_CERT_PUBKEY    0x98    /* Public key certificate */
  72. #define CTBTYPE_USERID        0xB4    /* UserID */
  73.  
  74. #define CTB_CERT_SECKEY     ( CTBTYPE_CERT_SECKEY | CTB_LEN_WORD )
  75. #define CTB_CERT_PUBKEY     ( CTBTYPE_CERT_PUBKEY | CTB_LEN_WORD )
  76. #define CTB_USERID            ( CTBTYPE_USERID | CTB_LEN_BYTE )
  77.  
  78. /* PGP version byte */
  79.  
  80. #define PGP_VERSION            2        /* PGP version 2.x */
  81.  
  82. /****************************************************************************
  83. *                                                                            *
  84. *                                PKCS Information                            *
  85. *                                                                            *
  86. ****************************************************************************/
  87.  
  88. /* Block types as per PKCS #1, Section 8 */
  89.  
  90. #define BT_PRIVATE    1        /* Block type for private-key operation */
  91. #define BT_PUBLIC    2        /* Block type for public-key operation */
  92.  
  93. /****************************************************************************
  94. *                                                                            *
  95. *                    ID Bytes and Packet Layout Information                    *
  96. *                                                                            *
  97. ****************************************************************************/
  98.  
  99. /* Public-key encryption algorithm selector bytes */
  100.  
  101. #define PKE_ALGORITHM_RSA        1    /* RSA */
  102.  
  103. /* Conventional encryption algorithm selector bytes */
  104.  
  105. #define CKE_ALGORITHM_NONE        0    /* Plaintext */
  106. #define CKE_ALGORITHM_IDEA        1    /* IDEA, CFB mode */
  107. #define CKE_ALGORITHM_MDC        64    /* MDC-128, CFB mode */
  108. #define CKE_ALGORITHM_MDC_R        65    /* MDC-128, CFB mode, rekeyed */
  109.  
  110. /* Signature algorithm selector bytes */
  111.  
  112. #define SIG_ALGORITHM_RSA        1    /* RSA */
  113.  
  114. /* Message digest algorithm selector bytes */
  115.  
  116. #define MD_ALGORITHM_MD5        1    /* MD5 message digest */
  117.  
  118. /* The length of the data in a message digest packet (the algo.ID byte, the
  119.    MD, and the timestamp), the length of the entire packet (the CTB, the
  120.    length byte, and the MD info length), and the offsets of various fields
  121.    within the packet */
  122.  
  123. #define MD_INFO_LENGTH            ( 1 + 16 + 4 )
  124. #define MD_PACKET_LENGTH        ( 1 + 1 + MD_INFO_LENGTH )
  125. #define MD_TIME_OFS                ( MD_INFO_LENGTH - sizeof( LONG ) )
  126. #define MD_DIGEST_OFS            sizeof( BYTE )
  127.  
  128. /* The length of the data in a PKE packet (the CTB, the length byte, the
  129.    algo.ID byte, and the DEK info) */
  130.  
  131. #define PKE_PACKET_LENGTH        ( 1 + 1 + 1 + BLOCKSIZE )
  132.  
  133. /* No.of bytes in key ID modulus fragment, and the number of bytes the user
  134.    sees */
  135.  
  136. #define KEYFRAG_SIZE             8        /* 64-bit keyID */
  137. #define KEYDISPLAY_SIZE            3        /* 24 bits shown to user */
  138.