Browse Source

[trac781] document to/from string

Jelte Jansen 14 years ago
parent
commit
238dca8216
2 changed files with 28 additions and 4 deletions
  1. 4 4
      src/lib/crypto/crypto.cc
  2. 24 0
      src/lib/crypto/crypto.h

+ 4 - 4
src/lib/crypto/crypto.cc

@@ -47,10 +47,10 @@ HashFunction* getHash(const Name& hash_name) {
     }
 }
 
-    // Library needs to have been inited during the entire program
-    // should we make this a singleton? (for hsm we'll need more
-    // initialization, and dynamic loading)
-    LibraryInitializer init;
+// Library needs to have been inited during the entire program
+// should we make this a singleton? (for hsm we'll need more
+// initialization, and dynamic loading)
+LibraryInitializer init;
 
 } // local namespace
 

+ 24 - 0
src/lib/crypto/crypto.h

@@ -84,8 +84,32 @@ bool verifyHMAC(const isc::dns::OutputBuffer& data,
                 isc::dns::TSIGKey key,
                 const isc::dns::OutputBuffer& mac);
 
+/// \brief Create a TSIGKey from an input string
+///
+/// This function takes an input string and creates a TSIG key
+/// from it. The string must be of the form:
+/// <name>:<secret>[:<algorithm>]
+/// Where <name> is a domain name for the key, <secret> is a
+/// base64 representation of the key secret, and the optional
+/// algorithm is an algorithm identifier as specified in RFC4635
+///
+/// Raises an InvalidParameter exception if the input string is
+/// invalid.
+///
+/// \param str The string to make a TSIGKey from
+/// \return The TSIGKey build from the string
 isc::dns::TSIGKey TSIGKeyFromString(const std::string& str);
 
+/// \brief Converts the given TSIGKey to a string value
+///
+/// The resulting string will be of the form
+/// name:secret:algorithm
+/// Where <name> is a domain name for the key, <secret> is a
+/// base64 representation of the key secret, and algorithm is
+/// an algorithm identifier as specified in RFC4635
+///
+/// \param key the TSIG key to convert
+/// \return The string representation of the given TSIGKey.
 std::string TSIGKeyToString(const isc::dns::TSIGKey& key);
 
 } // namespace crypto