~mdw
/
catacomb-perl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bcd9210
)
Add fill for encryption schemes.
author
mdw
<mdw>
Sun, 21 Nov 2004 03:32:32 +0000
(
03:32
+0000)
committer
mdw
<mdw>
Sun, 21 Nov 2004 03:32:32 +0000
(
03:32
+0000)
Catacomb/Crypto.pm
patch
|
blob
|
blame
|
history
algorithms.xs
patch
|
blob
|
blame
|
history
diff --git
a/Catacomb/Crypto.pm
b/Catacomb/Crypto.pm
index
c4e886d
..
85c7a3c
100644
(file)
--- a/
Catacomb/Crypto.pm
+++ b/
Catacomb/Crypto.pm
@@
-78,6
+78,19
@@
sub encrypt {
return $c->encrypt($p);
}
return $c->encrypt($p);
}
+sub fill {
+ croak("Usage: Catacomb::CipherClass::fill(cc, k, [iv], len)")
+ if @_ < 3 || @_ > 4;
+ my ($cc, $k, $iv, $len) = @_;
+ if (@_ == 3) {
+ $len = $iv;
+ $iv = undef;
+ }
+ my $c = $cc->init($k);
+ $c->setiv($iv) if defined($iv);
+ return $c->fill($len);
+}
+
sub decrypt {
croak("Usage: Catacomb::CipherClass::decrypt(cc, k, [iv], cipher)")
if @_ < 3 || @_ > 4;
sub decrypt {
croak("Usage: Catacomb::CipherClass::decrypt(cc, k, [iv], cipher)")
if @_ < 3 || @_ > 4;
@@
-91,6
+104,19
@@
sub decrypt {
return $c->decrypt($p);
}
return $c->decrypt($p);
}
+sub filldecrypt {
+ croak("Usage: Catacomb::CipherClass::filldecrypt(cc, k, [iv], len)")
+ if @_ < 3 || @_ > 4;
+ my ($cc, $k, $iv, $len) = @_;
+ if (@_ == 3) {
+ $len = $iv;
+ $iv = undef;
+ }
+ my $c = $cc->init($k);
+ $c->setiv($iv) if defined($iv);
+ return $c->filldecrypt($len);
+}
+
package Catacomb::HashClass;
use Carp;
package Catacomb::HashClass;
use Carp;
diff --git
a/algorithms.xs
b/algorithms.xs
index
6a01f15
..
1c9f5f1
100644
(file)
--- a/
algorithms.xs
+++ b/
algorithms.xs
@@
-227,6
+227,19
@@
encrypt(c, plain)
RETVAL
SV *
RETVAL
SV *
+fill(c, len)
+ gcipher *c
+ size_t len;
+ CODE:
+ RETVAL = NEWSV(0, len ? len : 1);
+ memset(SvPVX(RETVAL), 0, len);
+ c->ops->encrypt(c, SvPVX(RETVAL), SvPVX(RETVAL), len);
+ SvCUR_set(RETVAL, len);
+ SvPOK_on(RETVAL);
+ OUTPUT:
+ RETVAL
+
+SV *
decrypt(c, cipher)
gcipher *c
SV *cipher
decrypt(c, cipher)
gcipher *c
SV *cipher
@@
-243,6
+256,19
@@
decrypt(c, cipher)
RETVAL
SV *
RETVAL
SV *
+filldecrypt(c, len)
+ gcipher *c
+ size_t len;
+ CODE:
+ RETVAL = NEWSV(0, len ? len : 1);
+ memset(SvPVX(RETVAL), 0, len);
+ c->ops->decrypt(c, SvPVX(RETVAL), SvPVX(RETVAL), len);
+ SvCUR_set(RETVAL, len);
+ SvPOK_on(RETVAL);
+ OUTPUT:
+ RETVAL
+
+SV *
setiv(c, iv)
gcipher *c
SV *iv
setiv(c, iv)
gcipher *c
SV *iv