blob: 7df00a589c1fdbb75a3a17211379d084b31fb221 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001SYNOPSIS
Zesstrad59c3892019-11-28 20:53:39 +01002 #include <tls.h>
MG Mud User88f12472016-06-24 23:31:02 +02003
4 string hmac(int method, string key, string arg )
Zesstrad59c3892019-11-28 20:53:39 +01005 string hmac(int method, string key, bytes arg )
MG Mud User88f12472016-06-24 23:31:02 +02006 string hmac(int method, string key, int * arg )
Zesstrad59c3892019-11-28 20:53:39 +01007 string hmac(int method, bytes key, string arg )
8 string hmac(int method, bytes key, bytes arg )
9 string hmac(int method, bytes key, int * arg )
MG Mud User88f12472016-06-24 23:31:02 +020010
Zesstra715ec202025-07-09 22:18:31 +020011DESCRIPTION
12 Calculate the Hashed Message Authenication Code for <arg> based
13 on the digest <method> and the password <key>. Return the HMAC.
14 Any strings given as <key> or <arg> are converted to a UTF-8
15 byte sequence before being used.
MG Mud User88f12472016-06-24 23:31:02 +020016
Zesstra715ec202025-07-09 22:18:31 +020017 <method> is one of the TLS_HASH_ constants defined in tls.h; not
18 all recognized methods may be supported for a given driven:
MG Mud User88f12472016-06-24 23:31:02 +020019
20 TLS_HASH_SHA1 (1)
21 TLS_HASH_SHA224 (2)
22 TLS_HASH_SHA256 (3)
23 TLS_HASH_SHA384 (4)
24 TLS_HASH_SHA512 (5)
25 TLS_HASH_MD5 (6)
26 TLS_HASH_RIPEMD160 (7)
27
Zesstra715ec202025-07-09 22:18:31 +020028 If the driver is compiled without OpenSSL or GCrypt support
29 an error is thrown.
Zesstrad59c3892019-11-28 20:53:39 +010030
MG Mud User88f12472016-06-24 23:31:02 +020031
Zesstra715ec202025-07-09 22:18:31 +020032EXAMPLES
MG Mud User88f12472016-06-24 23:31:02 +020033 string s;
34
35 s = hmac(TLS_HASH_SHA1, "secret", "Hello");
36 s = hmac(TLS_HASH_SHA1, "secret", ({ 'H', 'e', 'l', 'l', 'o' }) )
37
Zesstra715ec202025-07-09 22:18:31 +020038HISTORY
39 Introduced in LDMud 3.3.714.
MG Mud User88f12472016-06-24 23:31:02 +020040
Zesstra715ec202025-07-09 22:18:31 +020041SEE ALSO
MG Mud User88f12472016-06-24 23:31:02 +020042 crypt(E), md5(E), md5_crypt(E), sha1(E), hmac(E)