MistServer  2.5.3-Pro-19-gf5e75b1 ( Generic_64)
auth.h
Go to the documentation of this file.
1 #pragma once
2 #include <string>
3 
4 namespace Secure {
5  //MD5 hashing functions
6  std::string md5(std::string input);
7  std::string md5(const char * input, const unsigned int in_len);
8  void md5bin(const char * input, const unsigned int in_len, char * output);
9 
10  //SHA256 hashing functions
11  std::string sha256(std::string input);
12  std::string sha256(const char * input, const unsigned int in_len);
13  void sha256bin(const char * input, const unsigned int in_len, char * output);
14 
15  //Generic HMAC functions
16  std::string hmac(std::string msg, std::string key, unsigned int hashSize, void hasher(const char *, const unsigned int, char*), unsigned int blockSize);
17  std::string hmac(const char * msg, const unsigned int msg_len, const char * key, const unsigned int key_len, unsigned int hashSize, void hasher(const char *, const unsigned int, char*), unsigned int blockSize);
18  void hmacbin(const char * msg, const unsigned int msg_len, const char * key, const unsigned int key_len, unsigned int hashSize, void hasher(const char*, const unsigned int, char*), unsigned int blockSize, char * output);
19  //Specific HMAC functions
20  std::string hmac_sha256(std::string msg, std::string key);
21  std::string hmac_sha256(const char * msg, const unsigned int msg_len, const char * key, const unsigned int key_len);
22  void hmac_sha256bin(const char * msg, const unsigned int msg_len, const char * key, const unsigned int key_len, char * output);
23 
24 }
25 
void hmacbin(const char *msg, const unsigned int msg_len, const char *key, const unsigned int key_len, unsigned int hashSize, void hasher(const char *, const unsigned int, char *), unsigned int blockSize, char *output)
Performs HMAC on msg with given key.
Definition: auth.cpp:294
std::string hmac_sha256(std::string msg, std::string key)
Convenience function that returns the hexadecimal alphanumeric HMAC-SHA256 of msg and key...
Definition: auth.cpp:321
std::string hmac(std::string msg, std::string key, unsigned int hashSize, void hasher(const char *, const unsigned int, char *), unsigned int blockSize)
Performs HMAC on msg with given key.
Definition: auth.cpp:272
std::string sha256(std::string input)
Calculates a SHA256 digest as per NSAs SHA-2, returning it as a hexadecimal alphanumeric string...
Definition: auth.cpp:27
void md5bin(const char *input, const unsigned int in_len, char *output)
Calculates a MD5 digest as per rfc1321, returning it as binary.
Definition: auth.cpp:87
void hmac_sha256bin(const char *msg, const unsigned int msg_len, const char *key, const unsigned int key_len, char *output)
Convenience function that sets output to the HMAC-SHA256 of msg and key in binary format...
Definition: auth.cpp:332
Definition: auth.cpp:8
void sha256bin(const char *input, const unsigned int in_len, char *output)
Calculates a SHA256 digest as per NSAs SHA-2, returning it as binary.
Definition: auth.cpp:196
std::string md5(std::string input)
Calculates a MD5 digest as per rfc1321, returning it as a hexadecimal alphanumeric string...
Definition: auth.cpp:11