siyuan-note/siyuan · error
Argon2id Iterations too high (maximum 10)
Error message
Argon2id Iterations too high (maximum 10)
What it means
ValidateArgon2Params caps Argon2id iterations at 10 to keep derivation latency bounded (unlock/enable operations stay responsive). More than 10 passes is rejected as excessive before any key is derived.
Solutions
- Set Argon2Params.Iterations to <= 10 (default 3 via util.DefaultArgon2Params())
- If more strength is needed, raise Memory up to the 256 MB cap first, keeping iterations in 3-10
- Edit the imported backup's crypto config JSON to valid values before importing
Example fix
// before
p := util.Argon2Params{Memory: 256 * 1024, Iterations: 100, Parallelism: 4, KeyLength: 32}
// after
p := util.Argon2Params{Memory: 256 * 1024, Iterations: 10, Parallelism: 4, KeyLength: 32} Defensive patterns
Strategy: validation
Validate before calling
if p.Iterations > 10 {
return fmt.Errorf("iterations must be <= 10, got %d", p.Iterations)
} Try / catch
if _, err := util.ValidateArgon2Params(p); err != nil {
return fmt.Errorf("invalid KDF params: %w", err)
} Prevention
- Do not port iteration counts from other tools' recommendations unbounded
- Increase strength via Memory (up to 256 MB) before touching iterations
- Clamp user-supplied values with a min/max helper before storing config
When it happens
Trigger: Calling ValidateArgon2Params (directly or via EnableEncryptedNotebook, ImportNotebookCryptoBackup, deriveKEK, or backup-restore paths) with Argon2Params.Iterations > 10, e.g. a hand-tuned config with 100 iterations.
Common situations: Manually 'hardening' the crypto config with very high iteration counts, porting parameters from another tool (e.g. OWASP CLI recommendations with higher passes), or importing a third-party backup with aggressive KDF settings.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Argon2id Memory too high (maximum 256 MB)
- Argon2id Parallelism must be between 1 and 16
- Argon2id Iterations too low (minimum 3)
- Argon2id KeyLength must be 32
- Argon2id Memory too low (minimum 64 MB)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/97ce6416059bd7a9.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/util/kdf.go:77
}
// ValidateArgon2Params 校验 Argon2id 参数是否在合理范围内,防止恶意备份设置极大内存导致 OOM,
// 或过弱参数降低安全性。
func ValidateArgon2Params(p Argon2Params) (Argon2Params, error) {
if p.KeyLength != 32 {
return p, errors.New("Argon2id KeyLength must be 32")
}
if p.Memory < 64*1024 {
return p, errors.New("Argon2id Memory too low (minimum 64 MB)")
}
if p.Memory > 256*1024 {
return p, errors.New("Argon2id Memory too high (maximum 256 MB)")
}
if p.Iterations < 3 {
return p, errors.New("Argon2id Iterations too low (minimum 3)")
}
if p.Iterations > 10 {
return p, errors.New("Argon2id Iterations too high (maximum 10)")
}
if p.Parallelism == 0 || p.Parallelism > 16 {
return p, errors.New("Argon2id Parallelism must be between 1 and 16")
}
return p, nil
}
// DeriveKey 用 Argon2id 从密码派生密钥。同一 password+salt+params 多次调用结果一致。
func DeriveKey(password string, salt []byte, p Argon2Params) []byte {
return argon2.IDKey([]byte(password), salt, p.Iterations, p.Memory, p.Parallelism, p.KeyLength)
}
// Encrypt 用 AES-256-GCM 加密。每次调用生成随机 nonce,因此同一明文多次加密结果不同。
// 返回格式:magic(4B) || spec(1B) || algorithm(1B) || nonceLength(1B) || nonce || ciphertext || GCM tag(16B)。
func Encrypt(key, plaintext []byte) ([]byte, error) {
return encryptGCM(key, plaintext, nil, "Encrypt")
}
View on GitHub (pinned to 9f775e8a12)