tags:

views:

44

answers:

0

It's possible in REBOL 3 to calculate a SHA1 module checksum. When REBOL loads a module, it compares its checksum against the checksum of the loaded module, and if the two do not match, an error is generated, viz. access error: invalid checksum (tampered file).

No matter how I try, I can't seem to create a module checksum that REBOL 3 likes. When I look at the documentation for import, its /check refinement says to use checksum/secure of mold/flat. I've tried all sorts of variations of this with no luck:

import/check %module.r checksum/secure to-binary mold/flat load/all %module.r
import/check %module.r checksum/secure to-binary mold/flat load %module.r
import/check %module.r checksum/secure to-binary mold/only/flat load/all %module.r
import/check %module.r checksum/secure to-binary mold/only/flat load %module.r
import/check %module.r checksum/secure read %module.r

and so on. None of it works. There's got to be some simple thing I'm doing wrong.

UPDATE:

I've voted to close this question because I figured it out by looking at the source code to REBOL 3's import function, which turned out to be a function! instead of a native! as I'd thought.

Here is the answer:

import/check %module.r checksum/secure to-binary mold/flat load/unbound/header %module.r

Of course, ordinarily you would pre-calculate the checksum and use it as a literal, otherwise it wouldn't do you much good as a security check:

import/check %module.r #{A3CD837D0CF843302221C074E88A64AA0147E07E}