Skip to content

Commit e8a8824

Browse files
committed
FIX: CHECKSUM/KEY argument doesn't allow binary! keys
Fixes: metaeducation/rebol-issues#1910
1 parent 767fd06 commit e8a8824

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

src/boot/natives.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ checksum: native [
383383
/method {Method to use}
384384
word [word!] {Methods: SHA1 SHA256 MD5 CRC32}
385385
/key {Returns keyed HMAC value}
386-
key-value [any-string!] {Key to use}
386+
key-value [any-string! binary!] {Key to use}
387387
]
388388

389389
compress: native [

src/core/n-strings.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static struct digest {
170170
** /method {Method to use}
171171
** word [word!] {Method: SHA1 MD5}
172172
** /key {Returns keyed HMAC value}
173-
** key-value [any-string!] {Key to use}
173+
** key-value [any-string! binary!] {Key to use}
174174
**
175175
***********************************************************************/
176176
{

src/tests/run-tests.r3

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ wrap load %units/mezz-crypt-test.r3
1616
wrap load %units/rsa-test.r3
1717
wrap load %units/dh-test.r3
1818
wrap load %units/port-test.r3
19+
wrap load %units/checksum-test.r3
1920

2021
wrap load %units/crash-test.r3
2122

src/tests/units/checksum-test.r3

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Rebol [
2+
Title: "Rebol checksum test script"
3+
Author: "Olds"
4+
File: %checksum-test.red
5+
Tabs: 4
6+
Needs: [%../quick-test-module.r3]
7+
]
8+
9+
~~~start-file~~~ "Checksum"
10+
11+
===start-group=== "Checksum with binary key (issue #1910)"
12+
;@@ https://github.com/rebol/rebol-issues/issues/1910
13+
--test-- "checksum-1"
14+
--assert #{800A1BC1B53CAA795F4DF39DC57652209239E1F1}
15+
= checksum/key to binary! "Hello world" "mykey"
16+
--assert #{800A1BC1B53CAA795F4DF39DC57652209239E1F1}
17+
= checksum/key to binary! "Hello world" to binary! "mykey"
18+
19+
20+
===end-group===
21+
22+
~~~end-file~~~

0 commit comments

Comments
 (0)