#xda #x41 #x59 #x7c #x51 #x57 #x48 #x8d
#x77 #x24 #xe0 #x3f #xb8 #xd8 #x4a #x37
#x6a #x43 #xb8 #xf4 #x15 #x18 #xa1 #x1c
- #xc3 #x87 #xb6 #x69 #xb2 #xee #x65 #x86))
\ No newline at end of file
+ #xc3 #x87 #xb6 #x69 #xb2 #xee #x65 #x86))
+
+(define (define-chacha-fencepost-test name)
+ (define-test (symbol 'chacha-fencepost/ name)
+ (lambda ()
+ (let ((output (make-bytevector 65))
+ (input (make-bytevector 16 0))
+ (key (make-bytevector 32 0))
+ (constant (string->utf8 "expand 32-byte k"))
+ (primitive (make-primitive-procedure name 5)))
+ (define (zv n) (make-bytevector n 0))
+ (primitive output 0 input key constant)
+ (primitive output 1 input key constant)
+ (assert-error (lambda () (primitive output -1 input key constant)))
+ (assert-error (lambda () (primitive output 2 input key constant)))
+ (assert-error (lambda () (primitive output 3 input key constant)))
+ (assert-error (lambda () (primitive output 64 input key constant)))
+ (assert-error (lambda () (primitive output 0 (zv 15) key constant)))
+ (assert-error (lambda () (primitive output 0 (zv 17) key constant)))
+ (assert-error (lambda () (primitive output 0 input (zv 31) constant)))
+ (assert-error (lambda () (primitive output 0 input (zv 33) constant)))
+ (assert-error (lambda () (primitive output 0 input key (zv 15))))
+ (assert-error (lambda () (primitive output 0 input key (zv 17))))))))
+
+(define-chacha-fencepost-test 'chacha8-core)
+(define-chacha-fencepost-test 'chacha12-core)
+(define-chacha-fencepost-test 'chacha20-core)
\ No newline at end of file