Skip to content

Commit

Permalink
[core] Protocol: set AES-GCM auth in the KM message.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsharabayko committed Oct 18, 2022
1 parent f637035 commit d5f73ca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion haicrypt/hcrypt_ctx_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ int hcryptCtx_Rx_ParseKM(hcrypt_Session *crypto, unsigned char *km_msg, size_t m
}
#endif

if (HCRYPT_AUTH_NONE != km_msg[HCRYPT_MSG_KM_OFS_AUTH]) {
if (HCRYPT_CIPHER_AES_GCM == km_msg[HCRYPT_MSG_KM_OFS_CIPHER]
&& HCRYPT_AUTH_AES_GCM != km_msg[HCRYPT_MSG_KM_OFS_AUTH]) {
HCRYPT_LOG(LOG_WARNING, "%s", "KMmsg GCM auth method was expected.\n");
return(-1);
}

if (HCRYPT_CIPHER_AES_CTR != km_msg[HCRYPT_MSG_KM_OFS_CIPHER]
&& HCRYPT_AUTH_NONE != km_msg[HCRYPT_MSG_KM_OFS_AUTH]) {
HCRYPT_LOG(LOG_WARNING, "%s", "KMmsg unsupported auth method\n");
return(-1);
}
Expand Down
2 changes: 1 addition & 1 deletion haicrypt/hcrypt_ctx_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ int hcryptCtx_Tx_AsmKM(hcrypt_Session *crypto, hcrypt_Ctx *ctx, unsigned char *a

/* crypto->KMmsg_cache[4..7]: KEKI=0 */
km_msg[HCRYPT_MSG_KM_OFS_CIPHER] = (ctx->mode == HCRYPT_CTX_MODE_AESGCM) ? HCRYPT_CIPHER_AES_GCM : HCRYPT_CIPHER_AES_CTR;
km_msg[HCRYPT_MSG_KM_OFS_AUTH] = HCRYPT_AUTH_NONE;
km_msg[HCRYPT_MSG_KM_OFS_AUTH] = (ctx->mode == HCRYPT_CTX_MODE_AESGCM) ? HCRYPT_AUTH_AES_GCM : HCRYPT_AUTH_NONE;
km_msg[HCRYPT_MSG_KM_OFS_SE] = (char) crypto->se;
hcryptMsg_KM_SetSaltLen(km_msg, ctx->salt_len);
hcryptMsg_KM_SetSekLen(km_msg, ctx->sek_len);
Expand Down
1 change: 1 addition & 0 deletions haicrypt/hcrypt_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ typedef struct {
#define HCRYPT_CIPHER_AES_GCM 4

#define HCRYPT_AUTH_NONE 0
#define HCRYPT_AUTH_AES_GCM 1

#define HCRYPT_SE_TSUDP 1
hcrypt_MsgInfo * hcryptMsg_STA_MsgInfo(void);
Expand Down

0 comments on commit d5f73ca

Please sign in to comment.