~ubuntu-branches/debian/lenny/dropbear/lenny

« back to all changes in this revision

Viewing changes to libtomcrypt/ocb_decrypt_verify_memory.c

  • Committer: Bazaar Package Importer
  • Author(s): Gerrit Pape
  • Date: 2005-05-25 22:38:17 UTC
  • mfrom: (1.2.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050525223817-fdl653extybmz1zb
Tags: 0.45-3
* debian/dropbear.init: init script prints human readable message in case
  it's disabled (closes: #309099).
* debian/dropbear.postinst: configure: restart service through init script
  instead of start.
* debian/dropbear.prerm: set -u -> set -e.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
          int           *res)
24
24
{
25
25
   int err;
26
 
   ocb_state ocb;
27
 
 
 
26
   ocb_state *ocb;
28
27
 
29
28
   _ARGCHK(key    != NULL);
30
29
   _ARGCHK(nonce  != NULL);
33
32
   _ARGCHK(tag    != NULL);
34
33
   _ARGCHK(res    != NULL);
35
34
 
36
 
   if ((err = ocb_init(&ocb, cipher, key, keylen, nonce)) != CRYPT_OK) {
37
 
      return err;
38
 
   }
39
 
 
40
 
   while (ctlen > (unsigned long)ocb.block_len) {
41
 
        if ((err = ocb_decrypt(&ocb, ct, pt)) != CRYPT_OK) {
42
 
           return err;
 
35
   /* allocate memory */
 
36
   ocb = XMALLOC(sizeof(ocb_state));
 
37
   if (ocb == NULL) {
 
38
      return CRYPT_MEM;
 
39
   }
 
40
 
 
41
   if ((err = ocb_init(ocb, cipher, key, keylen, nonce)) != CRYPT_OK) {
 
42
      goto __ERR; 
 
43
   }
 
44
 
 
45
   while (ctlen > (unsigned long)ocb->block_len) {
 
46
        if ((err = ocb_decrypt(ocb, ct, pt)) != CRYPT_OK) {
 
47
            goto __ERR; 
43
48
        }
44
 
        ctlen   -= ocb.block_len;
45
 
        pt      += ocb.block_len;
46
 
        ct      += ocb.block_len;
 
49
        ctlen   -= ocb->block_len;
 
50
        pt      += ocb->block_len;
 
51
        ct      += ocb->block_len;
47
52
   }
48
53
 
49
 
   return ocb_done_decrypt(&ocb, ct, ctlen, pt, tag, taglen, res);
 
54
   err = ocb_done_decrypt(ocb, ct, ctlen, pt, tag, taglen, res);
 
55
__ERR:
 
56
#ifdef CLEAN_STACK
 
57
   zeromem(ocb, sizeof(ocb_state));
 
58
#endif
 
59
 
 
60
   XFREE(ocb);
 
61
 
 
62
   return err;
50
63
}
51
64
 
52
65
#endif