… | |
… | |
23 | |
23 | |
24 | PROTOTYPES: ENABLE |
24 | PROTOTYPES: ENABLE |
25 | |
25 | |
26 | BOOT: |
26 | BOOT: |
27 | { |
27 | { |
28 | HV * stash = gv_stashpv ("Crypt::Twofish2", 0); |
28 | HV *stash = gv_stashpv ("Crypt::Twofish2", 0); |
29 | |
29 | |
30 | newCONSTSUB (stash, "keysize", newSViv (32)); |
30 | newCONSTSUB (stash, "keysize", newSViv (32)); |
31 | newCONSTSUB (stash, "blocksize", newSViv (16)); |
31 | newCONSTSUB (stash, "blocksize", newSViv (16)); |
32 | newCONSTSUB (stash, "MODE_ECB", newSViv (MODE_ECB)); |
32 | newCONSTSUB (stash, "MODE_ECB", newSViv (MODE_ECB)); |
33 | newCONSTSUB (stash, "MODE_CBC", newSViv (MODE_CBC)); |
33 | newCONSTSUB (stash, "MODE_CBC", newSViv (MODE_CBC)); |
… | |
… | |
80 | if (size % (BLOCK_SIZE >> 3)) |
80 | if (size % (BLOCK_SIZE >> 3)) |
81 | croak ("encrypt: datasize not multiple of blocksize (%d bits)", BLOCK_SIZE); |
81 | croak ("encrypt: datasize not multiple of blocksize (%d bits)", BLOCK_SIZE); |
82 | |
82 | |
83 | RETVAL = NEWSV (0, size); |
83 | RETVAL = NEWSV (0, size); |
84 | SvPOK_only (RETVAL); |
84 | SvPOK_only (RETVAL); |
|
|
85 | (SvPVX (RETVAL))[size] = 0; |
85 | SvCUR_set (RETVAL, size); |
86 | SvCUR_set (RETVAL, size); |
86 | |
87 | |
87 | if ((ix ? blockDecrypt : blockEncrypt) |
88 | if ((ix ? blockDecrypt : blockEncrypt) |
88 | (&self->ci, &self->ki, rawbytes, size << 3, (void *)SvPV_nolen(RETVAL)) < 0) |
89 | (&self->ci, &self->ki, rawbytes, size << 3, (void *)SvPV_nolen(RETVAL)) < 0) |
89 | croak ("block(De|En)crypt: unknown error, please report"); |
90 | croak ("block(De|En)crypt: unknown error, please report"); |