mac - 计算输入的消息验证代码
/usr/bin/mac -l
/usr/bin/mac [-v] -a algorithm [-t truncation] [-k keyfile | -K key_label [-T token_spec]] [file]...
The mac utility calculates the message authentication code (MAC) of the given file or files using the algorithm specified.
If no input file is specified, input is read from standard input.如果给定了多个文件,每个输出行就是单个文件的 MAC。
支持以下选项:
指定加密或解密过程中要使用的算法的名称。有关详细信息,请参见“用法”部分的“算法”。注意:不支持用于生成一般长度 MAC 的算法。
指定包含用于加密算法的密钥值的文件。每种算法都具有特定的密钥材料要求,如 PKCS#11 规范中所述。如果未指定 –k,mac 会使用getpassphrase(3C) 提示提供密钥材料。
指定 PKCS#11 令牌中的对称令牌密钥的标签。
显示系统上可用的算法列表。此列表可依加密框架的配置而变化。以位为单位显示密钥大小。
指定 PKCS#11 令牌,而不使用指定 –K 时的缺省软令牌对象存储。
token_spec 的格式为:
token_name [:manuf_id [:serial_no]]
当令牌标签包含结尾空格时,为方便起见,此选项不要求用户键入这些空格。
使用冒号分隔令牌标识字符串。如果任一部分中包含冒号 (:) 文本字符,必须使用反斜杠 (\) 对其进行转义。如果未找到冒号 (:),则将整个字符串(最多 32 个字符)视为令牌标签。如果仅找到一个冒号 (:),则该字符串是令牌标签和生产商。
指定摘要截断长度,其中 t 表示任何小于 512 的正数。Valid only for algorithm sha512_t_hmac.
Provides verbose information.
可使用 –l 选项显示受支持的算法。这些算法由加密框架提供。每个受支持的算法都是特定算法类型的最常用和受限最小版本的别名。例如,md5_hmac 是 CKM_MD5_HMAC 的别名。
这些别名与 –a 选项一起使用,并且区分大小写。
若在加密和解密任务期间未使用 –k 选项,则会提示用户提供口令短语。可使用 PKCS #5 中指定的 PBKDF2 算法将口令短语处理为更安全的密钥。
以下示例列出了可用的算法:
example$ mac -l Algorithm Keysize: Min Max (bits) ----------------------------------- sha1_hmac 8 512 md5_hmac 8 512 sha224_hmac 8 512 sha256_hmac 8 512 sha384_hmac 8 1024 sha512_hmac 8 1024 sha512_t_hmac 8 1024示例 2 获取消息验证代码
以下示例获取文件的消息验证代码:
example$ mac -v -k mykey -a sha1_hmac /export/foo sha1_hmac (/export/foo) = 913ced311df10f1708d9848641ca8992f4718057示例 3 使用令牌密钥获取消息验证代码
以下示例使用软令牌 keystore 中的通用令牌密钥获取消息验证代码。可使用 pktool(1) 生成通用令牌密钥:
example$ mac -v -a sha1_hmac -K my_generic_key \ -T "Sun Software PKCS#11 softtoken" /export/foo Enter pin for Sun Software PKCS#11 softtoken: sha1_hmac (/etc/foo) = c2ba5c38458c092a68940081240d22b670182968
将返回以下退出值:
成功完成。
出现错误。
有关下列属性的说明,请参见 attributes(7):
|
digest(1)、pktool(1)、getpassphrase(3C)、libpkcs11(3LIB)、attributes(7)、pkcs11_softtoken(7)、dd(8)
Kaliski, B., RFC 2898, PKCS #5: Password-Based Cryptography Specification, Version 2.0, September 2000. https://tools.ietf.org/html/rfc2898
https://www.oasis-open.org/committees/pkcs11/
Support for the des_mac algorithm was removed in Oracle Solaris 11.4.0.
The –t option and sha512_t_hmac algorithm were added in Solaris 11.4.0.
The sha224_hmac algorithm was added in Solaris 11.1.0.
The –K and –T options were added in Solaris 11.0.0.
The SHA-2 algorithms sha256_hmac, sha384_hmac, and sha512_hmac were added in Solaris 10 6/06 (Update 2).
The mac command, and all other other algorithms & options, were added in Solaris 10 3/05.