chiark
/
gitweb
/
~ian
/
chiark-tcl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
79480f2
)
Do not insist on iv if none wanted. If get_key failes, do not crash.
author
ian
<ian>
Tue, 10 Sep 2002 20:01:35 +0000
(20:01 +0000)
committer
ian
<ian>
Tue, 10 Sep 2002 20:01:35 +0000
(20:01 +0000)
crypto/crypto.c
patch
|
blob
|
history
diff --git
a/crypto/crypto.c
b/crypto/crypto.c
index ec6a6dec54ec1204e56a8f934917be2f17812272..39611580eb150ea4e792853db363578d550d4b0a 100644
(file)
--- a/
crypto/crypto.c
+++ b/
crypto/crypto.c
@@
-165,7
+165,7
@@
int do_hbytes_blockcipher(ClientData cd, Tcl_Interp *ip, int encrypt,
void *sched, **schedp;
want_bufferslen= alg->blocksize * (mode->buf_blocks + mode->iv_blocks);
void *sched, **schedp;
want_bufferslen= alg->blocksize * (mode->buf_blocks + mode->iv_blocks);
- key= get_key(ip, key_obj, alg, want_bufferslen);
+ key= get_key(ip, key_obj, alg, want_bufferslen);
if (!key) return TCL_ERROR;
schedp= (alg->decrypt.make_schedule==alg->encrypt.make_schedule
|| encrypt) ? &key->alpha : &key->beta;
schedp= (alg->decrypt.make_schedule==alg->encrypt.make_schedule
|| encrypt) ? &key->alpha : &key->beta;
@@
-181,7
+181,10
@@
int do_hbytes_blockcipher(ClientData cd, Tcl_Interp *ip, int encrypt,
}
iv_want= alg->blocksize * mode->iv_blocks;
}
iv_want= alg->blocksize * mode->iv_blocks;
- if (hbytes_issentinel(&iv)) {
+ if (!iv_want) {
+ if (!hbytes_issentinel(&iv))
+ return staticerr(ip,"iv supplied but mode does not take one");
+ } else if (hbytes_issentinel(&iv)) {
if (!encrypt) return staticerr(ip,"must supply iv when decrypting");
rc= get_urandom(ip, key->buffers, iv_want);
if (rc) return rc;
if (!encrypt) return staticerr(ip,"must supply iv when decrypting");
rc= get_urandom(ip, key->buffers, iv_want);
if (rc) return rc;