The procedures for encrypting and decrypting the session key encrypt_local_key and decrypt_remote_key are called in the get_common_key module. Both of these operations are performed in Extra Systems Cypher Net via the same long_power_mod function (modulo exponentiation), but they use different RSA keys: encryption is performed with one's own private key, and decryption is performed with the partner's public key.
typedef struct session_key_item
{
unsigned char packed[PACKED_VALUE_LENTH];
unsigned char unpacked[VALUE_LENTH];
} SESSIONKEYITEM;
SESSIONKEYITEM local_key, remote_key, common_key;
unsigned char crypted_local_key[PACKED_VALUE_LENTH], crypted_remote_key[PACKED_VALUE_LENTH];
void encrypt_local_key(void)
{
unsigned char crypted_value[VALUE_LENTH];
long_power_mod(local_key.unpacked, encrypt_rsa_key.exponent, encrypt_rsa_key.modulus, crypted_value);
pack_value(crypted_value, crypted_local_key);
}
void decrypt_remote_key(void)
{
unsigned char crypted_value[VALUE_LENTH];
unpack_value(crypted_remote_key, crypted_value);
long_power_mod(crypted_value, decrypt_rsa_key.exponent, decrypt_rsa_key.modulus, remote_key.unpacked);
pack_value(remote_key.unpacked, remote_key.packed);
}
The algorithm for the pack_value and unpack_value procedures can be found here.
The content of this page is also available in French, German, Portuguese, Spanish, Italian, Ukrainian and Russian.
| © Extra Systems, 2024 |
|