SMT2 formal verification of security-critical code paths
Subkey length must be 16-64 bytes. From crypto_kdf_blake2b_derive_from_key() in kdf_blake2b.c.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun subkey_len () Int)
(assert
(<= subkey_len 64))
(assert
(>= subkey_len 16))
(assert
(or (< subkey_len 16) (> subkey_len 64)))
(check-sat)
Subkey ID must fit uint64. From crypto_kdf_blake2b_derive_from_key().
; benchmark generated from python API
(set-info :status unknown)
(declare-fun subkey_id () Int)
(assert
(<= subkey_id 18446744073709551615))
(assert
(>= subkey_id 0))
(assert
(or (< subkey_id 0) (> subkey_id 18446744073709551615)))
(check-sat)
Message length ≤ SODIUM_SIZE_MAX - MACBYTES. From crypto_secretbox_easy().
; benchmark generated from python API
(set-info :status unknown)
(declare-fun mlen () Int)
(assert
(<= mlen 18446744073709551599))
(assert
(>= mlen 0))
(assert
(or (< mlen 0) (> mlen 18446744073709551599)))
(check-sat)
Ciphertext must be ≥ crypto_secretbox_MACBYTES (16). From crypto_secretbox_open_easy().
; benchmark generated from python API
(set-info :status unknown)
(declare-fun clen () Int)
(assert
(>= clen 16))
(assert
(< clen 16))
(check-sat)
After stripping MACBYTES, plaintext length must not underflow. From crypto_secretbox_open_easy().
; benchmark generated from python API
(set-info :status unknown)
(declare-fun clen () Int)
(assert
(>= clen 16))
(assert
(< (- clen 16) 0))
(check-sat)
crypto_secretbox_open_easy should only expose canonical return codes: -1 on auth/length failure, 0 on authenticated decrypt.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun ret () Int)
(assert
(let (($x28 (= ret 0)))
(let (($x14 (= ret (- 1))))
(or $x14 $x28))))
(assert
(and (and (distinct ret (- 1)) true) (and (distinct ret 0) true)))
(check-sat)
crypto_secretbox_open_detached should only expose canonical return codes: -1 on authentication failure, 0 on successful verification/decrypt.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun ret () Int)
(assert
(let (($x37 (= ret 0)))
(let (($x38 (= ret (- 1))))
(or $x38 $x37))))
(assert
(and (and (distinct ret (- 1)) true) (and (distinct ret 0) true)))
(check-sat)
crypto_secretbox_detached clamps mlen0 to 64-ZEROBYTES (32) before copying into block0.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun mlen0 () Int)
(assert
(<= mlen0 32))
(assert
(>= mlen0 0))
(assert
(or (< mlen0 0) (> mlen0 32)))
(check-sat)
crypto_secretbox_open_detached clamps mlen0 to 64-ZEROBYTES (32) before preloading block0.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun mlen0 () Int)
(assert
(<= mlen0 32))
(assert
(>= mlen0 0))
(assert
(or (< mlen0 0) (> mlen0 32)))
(check-sat)
crypto_box_open_detached_afternm delegates to crypto_secretbox_open_detached(), which clamps mlen0 to 32 before block0 preload.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun mlen0 () Int)
(assert
(<= mlen0 32))
(assert
(>= mlen0 0))
(assert
(or (< mlen0 0) (> mlen0 32)))
(check-sat)
crypto_box_open_detached should only expose canonical return codes: -1 on key setup failure, 0 on successful authenticated decrypt.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun ret () Int)
(assert
(let (($x34 (= ret 0)))
(let (($x26 (= ret (- 1))))
(or $x26 $x34))))
(assert
(and (and (distinct ret (- 1)) true) (and (distinct ret 0) true)))
(check-sat)
crypto_box_open_easy should only expose canonical return codes: -1 on length/auth failure, 0 on successful authenticated decrypt.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun ret () Int)
(assert
(let (($x14 (= ret 0)))
(let (($x9 (= ret (- 1))))
(or $x9 $x14))))
(assert
(and (and (distinct ret (- 1)) true) (and (distinct ret 0) true)))
(check-sat)
Box message length ≤ SODIUM_SIZE_MAX - MACBYTES. From crypto_box_easy().
; benchmark generated from python API
(set-info :status unknown)
(declare-fun mlen () Int)
(assert
(<= mlen 18446744073709551599))
(assert
(>= mlen 0))
(assert
(or (< mlen 0) (> mlen 18446744073709551599)))
(check-sat)
Afternm box path enforces message length ≤ SODIUM_SIZE_MAX - MACBYTES. From crypto_box_easy_afternm().
; benchmark generated from python API
(set-info :status unknown)
(declare-fun mlen () Int)
(assert
(<= mlen 18446744073709551599))
(assert
(>= mlen 0))
(assert
(or (< mlen 0) (> mlen 18446744073709551599)))
(check-sat)
Box ciphertext must be ≥ crypto_box_MACBYTES (16). From crypto_box_open_easy().
; benchmark generated from python API
(set-info :status unknown)
(declare-fun clen () Int)
(assert
(>= clen 16))
(assert
(< clen 16))
(check-sat)
After stripping MACBYTES, plaintext length must not underflow. From crypto_box_open_easy().
; benchmark generated from python API
(set-info :status unknown)
(declare-fun clen () Int)
(assert
(>= clen 16))
(assert
(< (- clen 16) 0))
(check-sat)
Afternm decrypt path requires ciphertext ≥ crypto_box_MACBYTES (16) before detached handoff.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun clen () Int)
(assert
(>= clen 16))
(assert
(< clen 16))
(check-sat)
Afternm detached handoff uses clen - crypto_box_MACBYTES; subtraction must not underflow.
; benchmark generated from python API
(set-info :status unknown)
(declare-fun clen () Int)
(assert
(>= clen 16))
(assert
(< (- clen 16) 0))
(check-sat)