Skip to content

Commit

Permalink
Identity Hash Support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh-Kumar-07 committed Aug 7, 2021
1 parent ac637de commit cf0dca3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/ike_alg_hash.h
Expand Up @@ -25,6 +25,8 @@ extern const struct hash_desc ike_alg_hash_sha2_384;
extern const struct hash_desc ike_alg_hash_sha2_512;
#endif

extern const struct hash_desc ike_alg_hash_identity;

#ifdef USE_MD5
extern const struct hash_desc ike_alg_hash_md5;
#endif
2 changes: 2 additions & 0 deletions include/pluto_constants.h
Expand Up @@ -997,13 +997,15 @@ enum sighash_policy_bits {
POL_SIGHASH_SHA2_256_IX,
POL_SIGHASH_SHA2_384_IX,
POL_SIGHASH_SHA2_512_IX,
POL_SIGHASH_IDENTITY_IX,
};

extern const struct enum_names sighash_policy_bit_names;

#define POL_SIGHASH_SHA2_256 LELEM(POL_SIGHASH_SHA2_256_IX)
#define POL_SIGHASH_SHA2_384 LELEM(POL_SIGHASH_SHA2_384_IX)
#define POL_SIGHASH_SHA2_512 LELEM(POL_SIGHASH_SHA2_512_IX)
#define POL_SIGHASH_IDENTITY LELEM(POL_SIGHASH_IDENTITY_IX)

/* Default policy for now is using RSA - this might change to ECC */
#define POLICY_DEFAULT POLICY_RSASIG
Expand Down
2 changes: 1 addition & 1 deletion lib/libipsecconf/confread.c
Expand Up @@ -185,7 +185,7 @@ static void ipsecconf_default_values(struct starter_config *cfg)
POLICY_ESN_NO; /* esn=no */

d->sighash_policy =
POL_SIGHASH_SHA2_256 | POL_SIGHASH_SHA2_384 | POL_SIGHASH_SHA2_512;
POL_SIGHASH_SHA2_256 | POL_SIGHASH_SHA2_384 | POL_SIGHASH_SHA2_512| POL_SIGHASH_IDENTITY;

d->left.host_family = &ipv4_info;
d->left.addr = ipv4_info.address.any;
Expand Down
13 changes: 13 additions & 0 deletions lib/libswan/ike_alg_sha2.c
Expand Up @@ -185,6 +185,19 @@ const struct hash_desc ike_alg_hash_sha2_384 = {
.hash_asn1_blob_ecdsa = THING_AS_HUNK(asn1_blob_ecdsa_sha2_384),
};

const struct hash_desc ike_alg_hash_identity = {
.common = {
.fqn = "IDENTITY_HASH",
.names = "IDENTITY_HASH",
.algo_type = IKE_ALG_HASH,
.id = {
[IKEv2_ALG_ID] = IKEv2_HASH_ALGORITHM_IDENTITY,
},
.fips = false,
},

};

const struct prf_desc ike_alg_prf_sha2_384 = {
.common = {
.fqn = "HMAC_SHA2_384",
Expand Down
8 changes: 6 additions & 2 deletions programs/pluto/ikev2_auth.c
Expand Up @@ -213,7 +213,11 @@ const struct hash_desc *v2_auth_negotiated_signature_hash(struct ike_sa *ike)
} else if (ike->sa.st_hash_negotiated & NEGOTIATE_AUTH_HASH_SHA2_256) {
hash_algo = &ike_alg_hash_sha2_256;
dbg("emit hash algo NEGOTIATE_AUTH_HASH_SHA2_256");
} else {
} else if (ike->sa.st_hash_negotiated & NEGOTIATE_AUTH_HASH_IDENTITY) {
hash_algo = &ike_alg_hash_identity;
dbg("emit hash algo NEGOTIATE_AUTH_HASH_IDENTITY");
}
else {
hash_algo = NULL;
dbg("DigSig: no compatible DigSig hash algo");
}
Expand Down Expand Up @@ -473,7 +477,7 @@ diag_t v2_authsig_and_log(enum ikev2_auth_method recv_auth,
{ NEGOTIATE_AUTH_HASH_SHA2_512, &ike_alg_hash_sha2_512 },
{ NEGOTIATE_AUTH_HASH_SHA2_384, &ike_alg_hash_sha2_384 },
{ NEGOTIATE_AUTH_HASH_SHA2_256, &ike_alg_hash_sha2_256 },
/* { NEGOTIATE_AUTH_HASH_IDENTITY, IKEv2_HASH_ALGORITHM_IDENTITY }, */
{ NEGOTIATE_AUTH_HASH_IDENTITY, &ike_alg_hash_identity },
};

const struct hash_alts *hap;
Expand Down

0 comments on commit cf0dca3

Please sign in to comment.