101 } |
101 } |
102 |
102 |
103 size_t aes_write(const void *buf, size_t s, size_t n, AESDecrypter *dec) { |
103 size_t aes_write(const void *buf, size_t s, size_t n, AESDecrypter *dec) { |
104 int len = s*n; |
104 int len = s*n; |
105 if(!dec->init) { |
105 if(!dec->init) { |
106 size_t n = 16 - dec->ivpos; |
106 size_t m = 16 - dec->ivpos; |
107 size_t cp = n > len ? len : n; |
107 size_t cp = m > len ? len : m; |
108 memcpy(dec->ivtmp + dec->ivpos, buf, cp); |
108 memcpy(dec->ivtmp + dec->ivpos, buf, cp); |
109 dec->ivpos += cp; |
109 dec->ivpos += cp; |
110 if(dec->ivpos >= 16) { |
110 if(dec->ivpos >= 16) { |
111 aes_decrypter_init(dec); |
111 aes_decrypter_init(dec); |
112 } |
112 } |