/* Static functions */
static SilcSKEStatus silc_ske_create_rnd(SilcSKE ske, SilcMPInt *n,
- uint32 len,
+ SilcUInt32 len,
SilcMPInt *rnd);
static SilcSKEStatus silc_ske_make_hash(SilcSKE ske,
unsigned char *return_hash,
- uint32 *return_hash_len,
+ SilcUInt32 *return_hash_len,
int initiator);
/* Structure to hold all SKE callbacks. */
silc_ske_payload_ke_free(ske->ke1_payload);
if (ske->ke2_payload)
silc_ske_payload_ke_free(ske->ke2_payload);
+ silc_free(ske->remote_version);
/* Free rest */
if (ske->prop) {
SilcBuffer payload_buf;
SilcMPInt *x;
SilcSKEKEPayload *payload;
- uint32 pk_len;
+ SilcUInt32 pk_len;
SILC_LOG_DEBUG(("Start"));
/* Compute signature data if we are doing mutual authentication */
if (private_key && ske->start_payload->flags & SILC_SKE_SP_FLAG_MUTUAL) {
unsigned char hash[32], sign[1024];
- uint32 hash_len, sign_len;
+ SilcUInt32 hash_len, sign_len;
SILC_LOG_DEBUG(("We are doing mutual authentication"));
SILC_LOG_DEBUG(("Computing HASH_i value"));
{
SilcSKEKEPayload *payload;
unsigned char hash[32];
- uint32 hash_len;
+ SilcUInt32 hash_len;
SilcPublicKey public_key = NULL;
/* If the SKE was freed during the async call then free it really now,
ske->start_payload->flags & SILC_SKE_SP_FLAG_MUTUAL) {
SilcPublicKey public_key = NULL;
unsigned char hash[32];
- uint32 hash_len;
+ SilcUInt32 hash_len;
/* Decode the public key */
if (!silc_pkcs_public_key_decode(recv_payload->pk_data,
SilcBuffer payload_buf;
SilcMPInt *KEY;
unsigned char hash[32], sign[1024], *pk;
- uint32 hash_len, sign_len, pk_len;
+ SilcUInt32 hash_len, sign_len, pk_len;
SILC_LOG_DEBUG(("Start"));
packet = silc_buffer_alloc(4);
silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
silc_buffer_format(packet,
- SILC_STR_UI_INT((uint32)SILC_SKE_STATUS_OK),
+ SILC_STR_UI_INT((SilcUInt32)SILC_SKE_STATUS_OK),
SILC_STR_END);
if (ske->callbacks->send_packet)
SILC_LOG_DEBUG(("Start"));
+ if (status > SILC_SKE_STATUS_INVALID_COOKIE)
+ status = SILC_SKE_STATUS_BAD_PAYLOAD;
+
packet = silc_buffer_alloc(4);
silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
silc_buffer_format(packet,
- SILC_STR_UI_INT((uint32)status),
+ SILC_STR_UI_INT((SilcUInt32)status),
SILC_STR_END);
if (ske->callbacks->send_packet)
}
}
+ ske->remote_version = silc_memdup(rp->version, rp->version_len);
+
/* Flags are returned unchanged. */
payload->flags = rp->flags;
of len bits. The rnd sent as argument must be initialized. */
static SilcSKEStatus silc_ske_create_rnd(SilcSKE ske, SilcMPInt *n,
- uint32 len,
+ SilcUInt32 len,
SilcMPInt *rnd)
{
SilcSKEStatus status = SILC_SKE_STATUS_OK;
static SilcSKEStatus silc_ske_make_hash(SilcSKE ske,
unsigned char *return_hash,
- uint32 *return_hash_len,
+ SilcUInt32 *return_hash_len,
int initiator)
{
SilcSKEStatus status = SILC_SKE_STATUS_OK;
SilcBuffer buf;
unsigned char *e, *f, *KEY;
- uint32 e_len, f_len, KEY_len;
+ SilcUInt32 e_len, f_len, KEY_len;
int ret;
SILC_LOG_DEBUG(("Start"));
KEY = silc_mp_mp2bin(ske->KEY, 0, &KEY_len);
/* Format the buffer used to compute the hash value */
- /* XXX Backward support for 0.6.1 */
- if (ske->backward_version == 1) {
- SILC_LOG_DEBUG(("*********** Using old KE payload"));
- buf = silc_buffer_alloc(ske->start_payload_copy->len +
- ske->ke2_payload->pk_len + e_len +
- f_len + KEY_len);
- silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
+ buf = silc_buffer_alloc(ske->start_payload_copy->len +
+ ske->ke2_payload->pk_len +
+ ske->ke1_payload->pk_len +
+ e_len + f_len + KEY_len);
+ silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
+ /* Initiator is not required to send its public key */
+ if (!ske->ke1_payload->pk_data) {
ret =
silc_buffer_format(buf,
- SILC_STR_UI_XNSTRING(ske->start_payload_copy->data,
- ske->start_payload_copy->len),
+ SILC_STR_UI_XNSTRING(ske->start_payload_copy->
+ data,
+ ske->start_payload_copy->
+ len),
SILC_STR_UI_XNSTRING(ske->ke2_payload->pk_data,
ske->ke2_payload->pk_len),
SILC_STR_UI_XNSTRING(e, e_len),
SILC_STR_UI_XNSTRING(KEY, KEY_len),
SILC_STR_END);
} else {
- /* Initiator is not required to send its public key */
- SILC_LOG_DEBUG(("*********** Using new KE payload"));
- buf = silc_buffer_alloc(ske->start_payload_copy->len +
- ske->ke2_payload->pk_len +
- ske->ke1_payload->pk_len +
- e_len + f_len + KEY_len);
- silc_buffer_pull_tail(buf, SILC_BUFFER_END(buf));
-
- if (!ske->ke1_payload->pk_data) {
- ret =
- silc_buffer_format(buf,
- SILC_STR_UI_XNSTRING(ske->start_payload_copy->
- data,
- ske->start_payload_copy->
- len),
- SILC_STR_UI_XNSTRING(ske->ke2_payload->pk_data,
- ske->ke2_payload->pk_len),
- SILC_STR_UI_XNSTRING(e, e_len),
- SILC_STR_UI_XNSTRING(f, f_len),
- SILC_STR_UI_XNSTRING(KEY, KEY_len),
- SILC_STR_END);
- } else {
- ret =
- silc_buffer_format(buf,
- SILC_STR_UI_XNSTRING(ske->start_payload_copy->
- data,
- ske->start_payload_copy->
- len),
- SILC_STR_UI_XNSTRING(ske->ke2_payload->pk_data,
- ske->ke2_payload->pk_len),
- SILC_STR_UI_XNSTRING(ske->ke1_payload->pk_data,
- ske->ke1_payload->pk_len),
- SILC_STR_UI_XNSTRING(e, e_len),
- SILC_STR_UI_XNSTRING(f, f_len),
- SILC_STR_UI_XNSTRING(KEY, KEY_len),
- SILC_STR_END);
- }
+ ret =
+ silc_buffer_format(buf,
+ SILC_STR_UI_XNSTRING(ske->start_payload_copy->
+ data,
+ ske->start_payload_copy->
+ len),
+ SILC_STR_UI_XNSTRING(ske->ke2_payload->pk_data,
+ ske->ke2_payload->pk_len),
+ SILC_STR_UI_XNSTRING(ske->ke1_payload->pk_data,
+ ske->ke1_payload->pk_len),
+ SILC_STR_UI_XNSTRING(e, e_len),
+ SILC_STR_UI_XNSTRING(f, f_len),
+ SILC_STR_UI_XNSTRING(KEY, KEY_len),
+ SILC_STR_END);
}
if (ret == -1) {
silc_buffer_free(buf);
/* Make the hash */
silc_hash_make(ske->prop->hash, buf->data, buf->len, return_hash);
- *return_hash_len = ske->prop->hash->hash->hash_len;
+ *return_hash_len = silc_hash_len(ske->prop->hash);
if (initiator == FALSE) {
SILC_LOG_HEXDUMP(("HASH"), return_hash, *return_hash_len);
SilcSKEStatus
silc_ske_process_key_material_data(unsigned char *data,
- uint32 data_len,
- uint32 req_iv_len,
- uint32 req_enc_key_len,
- uint32 req_hmac_key_len,
+ SilcUInt32 data_len,
+ SilcUInt32 req_iv_len,
+ SilcUInt32 req_enc_key_len,
+ SilcUInt32 req_hmac_key_len,
SilcHash hash,
SilcSKEKeyMaterial *key)
{
SilcBuffer buf;
unsigned char hashd[32];
- uint32 hash_len = req_hmac_key_len;
- uint32 enc_key_len = req_enc_key_len / 8;
+ SilcUInt32 hash_len = req_hmac_key_len;
+ SilcUInt32 enc_key_len = req_enc_key_len / 8;
SILC_LOG_DEBUG(("Start"));
the actual keys to be used in the SILC. */
SilcSKEStatus silc_ske_process_key_material(SilcSKE ske,
- uint32 req_iv_len,
- uint32 req_enc_key_len,
- uint32 req_hmac_key_len,
+ SilcUInt32 req_iv_len,
+ SilcUInt32 req_enc_key_len,
+ SilcUInt32 req_hmac_key_len,
SilcSKEKeyMaterial *key)
{
SilcSKEStatus status;
SilcBuffer buf;
unsigned char *tmpbuf;
- uint32 klen;
+ SilcUInt32 klen;
/* Encode KEY to binary data */
tmpbuf = silc_mp_mp2bin(ske->KEY, 0, &klen);
return "";
}
+
+/* Parses remote host's version string. */
+
+bool silc_ske_parse_version(SilcSKE ske,
+ SilcUInt32 *protocol_version,
+ char **protocol_version_string,
+ SilcUInt32 *software_version,
+ char **software_version_string,
+ char **vendor_version)
+{
+ return silc_parse_version_string(ske->remote_version,
+ protocol_version,
+ protocol_version_string,
+ software_version,
+ software_version_string,
+ vendor_version);
+}