+ /* Add padding */
+
+ if(n->cipherblklen > 1) {
+ int padlen, i;
+ uint8_t *p;
+
+ padlen = n->cipherblklen - inpkt->len % n->cipherblklen;
+ p = (char *)&inpkt->seqno + inpkt->len;
+
+ if(padlen == n->cipherblklen) {
+ if(p[-1] != 0 && p[-1] <= n->cipherblklen) {
+ inpkt->len += n->cipherblklen;
+ for(i = 0; i < n->cipherblklen; i++)
+ *p++ = i + 1;
+ }
+ } else {
+ inpkt->len += padlen;
+ for(i = 0; i < padlen; i++)
+ *p++ = i + 1;
+ }
+ }
+
+ gcry_cipher_reset(n->cipher_ctx);
+ //memcpy(iv, &inpkt->seqno, sizeof inpkt->seqno);
+ //gcry_cipher_setiv(n->cipher_ctx, iv, n->cipherblklen);
+ result = gcry_cipher_encrypt(n->cipher_ctx, (char *)&inpkt->seqno, inpkt->len, NULL, 0);