ccgcm_ctx ctxt[0];
} aes_gcm_ctx;
-int
+size_t
esp_aes_schedlen(
__unused const struct esp_algorithm *algo)
{
return EINVAL;
}
+ VERIFY(ivoff <= INT_MAX);
+
/* grab iv */
- m_copydata(m, ivoff, ivlen, (caddr_t) iv);
+ m_copydata(m, (int)ivoff, ivlen, (caddr_t) iv);
s = m;
soff = sn = dn = 0;
/* skip header/IV offset */
while (soff < bodyoff) {
if (soff + s->m_len > bodyoff) {
- sn = bodyoff - soff;
+ sn = (int)(bodyoff - soff);
break;
}
m_adj(d, IPSEC_GET_P2UNALIGNED_OFS(d->m_data));
}
- d->m_len = M_TRAILINGSPACE(d);
+ d->m_len = (int)M_TRAILINGSPACE(d);
d->m_len -= d->m_len % AES_BLOCKLEN;
if (d->m_len > i) {
d->m_len = i;
bodyoff = off + sizeof(struct newesp) + ivlen;
}
+ VERIFY(ivoff <= INT_MAX);
+
/* put iv into the packet */
- m_copyback(m, ivoff, ivlen, sav->iv);
+ m_copyback(m, (int)ivoff, ivlen, sav->iv);
ivp = (u_int8_t *) sav->iv;
if (m->m_pkthdr.len < bodyoff) {
/* skip headers/IV */
while (soff < bodyoff) {
if (soff + s->m_len > bodyoff) {
- sn = bodyoff - soff;
+ sn = (int)(bodyoff - soff);
break;
}
m_adj(d, IPSEC_GET_P2UNALIGNED_OFS(d->m_data));
}
- d->m_len = M_TRAILINGSPACE(d);
+ d->m_len = (int)M_TRAILINGSPACE(d);
d->m_len -= d->m_len % AES_BLOCKLEN;
if (d->m_len > i) {
d->m_len = i;
return 0;
}
-int
+size_t
esp_gcm_schedlen(
__unused const struct esp_algorithm *algo)
{
int
esp_gcm_encrypt_finalize(struct secasvar *sav,
- unsigned char *tag, unsigned int tag_bytes)
+ unsigned char *tag, size_t tag_bytes)
{
aes_gcm_ctx *ctx = (aes_gcm_ctx*)P2ROUNDUP(sav->sched, ESP_GCM_ALIGN);
return aes_encrypt_finalize_gcm(tag, tag_bytes, ctx->encrypt);
int
esp_gcm_decrypt_finalize(struct secasvar *sav,
- unsigned char *tag, unsigned int tag_bytes)
+ unsigned char *tag, size_t tag_bytes)
{
aes_gcm_ctx *ctx = (aes_gcm_ctx*)P2ROUNDUP(sav->sched, ESP_GCM_ALIGN);
return aes_decrypt_finalize_gcm(tag, tag_bytes, ctx->decrypt);
return EINVAL;
}
+ VERIFY(ivoff <= INT_MAX);
+
/*
* The IV is now generated within corecrypto and
* is provided to ESP using aes_encrypt_inc_iv_gcm().
* this value will get the latest IV.
*/
memcpy(sav->iv, (nonce + ESP_GCM_SALT_LEN), ivlen);
- m_copyback(m, ivoff, ivlen, sav->iv);
+ m_copyback(m, (int)ivoff, ivlen, sav->iv);
bzero(nonce, ESP_GCM_SALT_LEN + ivlen);
if (m->m_pkthdr.len < bodyoff) {
return EINVAL;
}
+ VERIFY(off <= INT_MAX);
+
/* Set Additional Authentication Data */
if (!(sav->flags & SADB_X_EXT_OLD)) {
struct newesp esp;
- m_copydata(m, off, sizeof(esp), (caddr_t) &esp);
+ m_copydata(m, (int)off, sizeof(esp), (caddr_t) &esp);
if (aes_encrypt_aad_gcm((unsigned char*)&esp, sizeof(esp), ctx->encrypt)) {
ipseclog((LOG_ERR, "%s: packet decryption AAD failure\n", __FUNCTION__));
m_freem(m);
/* skip headers/IV */
while (soff < bodyoff) {
if (soff + s->m_len > bodyoff) {
- sn = bodyoff - soff;
+ sn = (int)(bodyoff - soff);
break;
}
m_adj(d, IPSEC_GET_P2UNALIGNED_OFS(d->m_data));
}
- d->m_len = M_TRAILINGSPACE(d);
+ d->m_len = (int)M_TRAILINGSPACE(d);
if (d->m_len > i) {
d->m_len = i;
return EINVAL;
}
+ VERIFY(ivoff <= INT_MAX);
+
/* grab iv */
- m_copydata(m, ivoff, ivlen, (caddr_t) iv);
+ m_copydata(m, (int)ivoff, ivlen, (caddr_t) iv);
/* Set IV */
memcpy(nonce, _KEYBUF(sav->key_enc) + _KEYLEN(sav->key_enc) - ESP_GCM_SALT_LEN, ESP_GCM_SALT_LEN);
}
bzero(nonce, sizeof(nonce));
+ VERIFY(off <= INT_MAX);
+
/* Set Additional Authentication Data */
if (!(sav->flags & SADB_X_EXT_OLD)) {
struct newesp esp;
- m_copydata(m, off, sizeof(esp), (caddr_t) &esp);
+ m_copydata(m, (int)off, sizeof(esp), (caddr_t) &esp);
if (aes_decrypt_aad_gcm((unsigned char*)&esp, sizeof(esp), ctx->decrypt)) {
ipseclog((LOG_ERR, "%s: packet decryption AAD failure\n", __FUNCTION__));
return EINVAL;
/* skip header/IV offset */
while (soff < bodyoff) {
if (soff + s->m_len > bodyoff) {
- sn = bodyoff - soff;
+ sn = (int)(bodyoff - soff);
break;
}
m_adj(d, IPSEC_GET_P2UNALIGNED_OFS(d->m_data));
}
- d->m_len = M_TRAILINGSPACE(d);
+ d->m_len = (int)M_TRAILINGSPACE(d);
if (d->m_len > i) {
d->m_len = i;