0

我遇到了一个关于 Yubikey 的 OTP 验证的理解问题我正在尝试开发验证协议 V2 ( https://developers.yubico.com/OTP/Specifications/OTP_validation_protocol.html )

我不明白您如何获得我使用来自https://developers.yubico.com/OTP/Specifications/Test_vectors.html的矢量测试的签名

我的代码是

String apiKey = 'mG5be6ZJU1qBGz24yPh/ESM3UdU=';
String keyValue = 'id=1&nonce=jrFwbaYFhn0HoxZIsd9LQ6w2ceU&otp=vvungrrdhvtklknvrtvuvbbkeidikkvgglrvdgrfcdft';
var hmacSha1 = crypto.Hmac(crypto.sha1, apiKey.codeUnits);
crypto.Digest sha1Result = hmacSha1.convert(keyValue.codeUnits);
String hEncode64 = base64.encode(sha1Result.bytes);
final http.Response responseHttp = await http.get(
        Uri.parse('https://api.yubico.com/wsapi/2.0/verify?' +
            keyValue +
            '&h=' +
            hEncode64),
);

我没有找到与 Vector Test (h=%2Bja8S3IjbX593/LAgTBixwPNGX4%3D) 相同的结果。-> +ja8S3IjbX593/LAgTBixwPNGX4= 但我的误解是:当我尝试对你的矢量测试进行base64解码时,我不能,因为它不是utf8格式

当我尝试使用现场可用的测试向量时,它不起作用

https://api.yubico.com/wsapi/2.0/verify?id=1&otp=vvungrrdhvtklknvrtvuvbbkeidikkvgglrvdgrfcdft&nonce=jrFwbaYFhn0HoxZIsd9LQ6w2ceU&h=%2Bja8S3IjbX593/LAgTBixwPNGX4%3D
h=JE5WcMcXV7vooWkeN2/7A4DpMFo=
t=2021-12-15T12:51:37Z0635
status=BAD_SIGNATURE

你能帮我理解吗?请我的pb

4

0 回答 0