SECURITY 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. ----------------------------
  2. Security Design of openais
  3. ----------------------------
  4. The openais project uses code from the libtomcrypt package (www.libtomcrypt.org)
  5. for most of the algorithms described in this document. The libtomcrypt code has
  6. a public domain license.
  7. The openais project intends to mitigate the following threats:
  8. 1. forged group messaging messages which are intended to fault the openais
  9. executive
  10. 2. forged group messaging messages which are intended to fault applications
  11. using openais apis
  12. 3. monitoring of network data to capture sensitive information
  13. The openais project does not intend to mitigate the following threats:
  14. 1. physical access to the hardware which could expose the private key
  15. 2. privledged access to the operating system which could expose the private key
  16. or be used to inject errors into the ais executive.
  17. 3. library user creates requests which are intended to fault the openais
  18. executive
  19. The openais project mitigates the threats using two mechanisms:
  20. 1. Authentication
  21. 2. Secrecy
  22. Library Interface
  23. -----------------
  24. The openais executive authenticates every library user. The library is only
  25. allowed to access services if it's GID is ais or 0. Unauthorized library
  26. users are rejected.
  27. The ais group is a trusted group. If the administrator doesn't trust the
  28. application, it should not be added to the group! Any member of the ais group
  29. could potentially send a malformed request to the executive and cause it to
  30. fault.
  31. Group Messaging Interface
  32. -------------------------
  33. Group messaging uses UDP/IP to communicate with other openais executives using
  34. messages. It is possible without authentication of every packet that an
  35. attacker could forge messages. These forged messages could fault the openais
  36. executive distributed state machines. It would also be possible to corrupt
  37. end applications by forging updates
  38. Since messages are sent using UDP/IP it would be possible to snoop those
  39. messages and rebuild sensitive data.
  40. To solve these problems, the group messaging interface uses two new interfaces
  41. interal to it's implementation:
  42. 1. ctr_encrypt_and_sign - encrypts and signs a message securely
  43. 2. ctr_authenticate_and_decrypt - authenticates and decrypts a message securely
  44. When the executive wants to send a message over the network, it uses
  45. ctr_encrypt_and_sign to prepare the message to be sent. When the executive
  46. wants to receive a message from the network, it uses
  47. ctr_authenticate_and_decrypt to verify the message is valid and decrypt it.
  48. These two functions utilize the following algorithms:
  49. yarrow - secure pseudo random number generator
  50. pkcs #5 alg #2 - Converts a random and secret key into a larger key
  51. md4 - hash algorithm secure for using with yarrow and pkcs
  52. sha1 - hash algorithm secure for using with hmac
  53. hmac - produces a 20 byte sha1 digest from any length input and a 16 byte key
  54. blowfish - cipher algorithm - encrypts one block of data
  55. ctr - Counter mode of ciphering - encrypts variable length data blocks
  56. The hmac algorithm requires a 16 byte key.
  57. The blowfish algorithm requires a 16 byte key.
  58. The ctr algorithm requires a 16 byte nonce.
  59. The private key is read from disk and stored in memory for use with the
  60. pkcs #5 alg #2 operation.
  61. Every message starts with a
  62. struct digest {
  63. unsigned char digest[20]; A one way hash digest
  64. };
  65. struct salt {
  66. unsigned char salt[16]; A securely generated random number
  67. };
  68. struct sec_hdr {
  69. struct digest;
  70. struct salt;
  71. }
  72. The sec_hdr.digest is never hashed or encrypted by the algorithms described.
  73. The sec_hdr.salt is never encrypted, but is hashed by the algoriths described.
  74. When a message is sent (ctr_encrypt_and_sign):
  75. ----------------------------------------------
  76. 1. yarrow is used to create a 16 byte random number (salt) using the md4
  77. algorithm
  78. 2. pkcs #5 alg #2 is used with the salt and private key to create a 48 byte
  79. key. This 48 byte key is split into 3 16 byte keys. The keys are the
  80. hmac key, the blowfish key, and the ctr nonce key. pkcs uses the md4
  81. algorithm.
  82. 3. The ctr nonce and blowfish key from step #2 are used to setup the ctr cipher
  83. for use with blowfish.
  84. 4. The data of the packet, except for the sec_hdr, is encrypted using
  85. the ctr cipher that was initialized in step #3.
  86. 5. The salt is stored in the sec_hdr header of the outgoing message.
  87. 6. The hmac is initialized with the hmac key generated in step #2.
  88. 7. The message, except for the sec_hdr.digest, is hmaced to produce a digest
  89. using the sha1 algorithm.
  90. 8. The digest is stored in the outgoing message.
  91. 9. The message is transmitted.
  92. When a message is received (ctr_decrypt_and_authenticate):
  93. ---------------------------------------------------------
  94. 1. yarrow is used to create a 16 byte random number (salt) using the md4
  95. algorithm
  96. 2. pkcs #5 alg #2 is used with the salt and private key to create a 48 byte
  97. key. This 48 byte key is split into 3 16 byte keys. The keys are the
  98. hmac key, the blowfish key, and the ctr nonce key. pkcs uses the md4
  99. algorithm.
  100. 3. The ctr nonce and blowfish key from step #2 are used to setup the ctr cipher
  101. for use with blowfish.
  102. 4. The hmac is setup using the hmac key generated in step #2 using sha1.
  103. 5. The message is authenticated, except for the sec_hdr.digest.
  104. 6. If the message was not authenticated, the caller is told of the result.
  105. The caller ignores the message.
  106. 7. The message is decrypted, except for the sec_hdr, using the ctr
  107. initialized in step #3.
  108. 8. The message is processed.
  109. This does consume some resources. It ensures the private key is never shared
  110. openly. All messages are authenticated and encrypted. An exposure of
  111. one of the nonce key, blowfish key, or hmac key can only be used to
  112. attack the key relating to the algorithm. Finally every key used is
  113. randomly unique (within the 2^128 search space of the input to pkcs) to ensure
  114. that keys are never reused, nonce's are never reused, and hmac's are never
  115. reused in combination with each other.
  116. Comments welcome mailto:openais@lists.osdl.org