我对安全性的东西不是很熟悉,但是遇到过这个用于防止定时攻击的恒定时间功能:
// shortcutting on type is necessary for correctness
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
return false;
}
// buffer sizes should be well-known information, so despite this
// shortcutting, it doesn't leak any information about the *contents* of the
// buffers.
if (a.length !== b.length) {
return false;
}
var c = 0;
for (var i = 0; i < a.length; i++) {
/*jshint bitwise:false */
c |= a[i] ^ b[i]; // XOR
}
return c === 0;
https://github.com/salesforce/buffer-equal-constant-time/blob/master/index.js
在考虑定时攻击时,想知道是否有标准的事情需要注意,以及上述的技术来解决这些问题。类似于OWASP 的 XSS 备忘单。谢谢!