c - 从编码的哈希值中导出 Argon2 类型是否安全?

标签 c security cryptography passwords

我正在尝试使用 Argon2 引用实现,但我对验证期间类型参数 (i、d、id) 的使用有点困惑。

对于密码验证,我需要调用库的 *verify* 函数之一。这些函数带有“高级”API:

/**
 * Verifies a password against an encoded string
 * Encoded string is restricted as in validate_inputs()
 * @param encoded String encoding parameters, salt, hash
 * @param pwd Pointer to password
 * @pre   Returns ARGON2_OK if successful
 */
ARGON2_PUBLIC int argon2i_verify(const char *encoded, const void *pwd, const size_t pwdlen);
ARGON2_PUBLIC int argon2d_verify(const char *encoded, const void *pwd, const size_t pwdlen);
ARGON2_PUBLIC int argon2id_verify(const char *encoded, const void *pwd, const size_t pwdlen);
/* generic function underlying the above ones */
ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen, argon2_type type);

令人困惑的部分是为什么我必须选择调用哪个方法(或者在泛型函数的 argon2_type type 中放入什么),因为类型已经包含在 char *编码?

从应用程序的角度来看,我需要事先知道每个密码使用的是哪种类型。但是......这就是编码的全部意义所在。如果只有一个 *verify* 函数不是很好吗?

ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen);

哪个将从编码值派生类型?

所以,问题是:

  • RI 当前的 API 设计是否告诉我一些关于安全性的信息,或者 可用性是开发人员并没有真正做到万无一失的东西?
  • 从编码值派生类型是否安全,还是我应该选择一种类型并坚持使用(也称为硬编码)?

谢谢

最佳答案

The confusing part is why do I have to choose which method to call (or what to put in argon2_type type on the generic function), since the type is already contained in char *encoded? ... Does the RI current API design tells me something about security, or usability was something the developers didn't really bulletproof?

恐怕只有作者才能回答这个问题。但是,一般而言,引用实现可能不像为 argon2 的开发人员()而非库的用户设计的那样用户友好。

Is it safe to derive the type from the encoded value, or should I choose one type and stick with it (aka hardcode it)?

禁止降级是有意义的,使这种过滤可配置可能是明智的。

最后,即使对手完全控制了参数,对手也不太可能发现碰撞 - 因此它并不过分关键。

我个人喜欢指定一个与实际参数分开的特定协议(protocol)版本,然后指定要使用的算法。

关于c - 从编码的哈希值中导出 Argon2 类型是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47650232/

相关文章:

c - 寻找多维数组中的最小元素

c - 在 C 中转换为较大类型时填充值

c - 如何找到 PICmicro C 编译器的数据类型大小?

java - x^n–1 多项式的结果

c# - 访问 RSA key 容器

c - 这个movl指令有必要吗?

node.js - 无服务器出站流量保护

php - 在浏览器中显示文件而不透露其位置

java - RMI:远程对象的字段是否被序列化并发送到客户端?

algorithm - 我应该如何格式化数字签名?