iasrequest.cpp
// Encrypt the subscription key while its stored in memory
Encrypt the subscription key while its stored in memory
Encrypt the subscription key while its stored in memory
int IAS_Connection::setSubscriptionKey(SubscriptionKeyID id, char * subscriptionKeyPlainText)
{
        memset(subscription_key_enc[id], 0, sizeof(subscription_key_enc[id]));
        memset(subscription_key_xor[id], 0, sizeof(subscription_key_xor[id]));
        if (subscriptionKeyPlainText == NULL || (strlen(subscriptionKeyPlainText) != IAS_SUBSCRIPTION_KEY_SIZE) ||
	    (id == SubscriptionKeyID::Last))
        {
                if ( debug )
                        eprintf("Error Setting subscriptionKey\n");
                return 0;
        }
    RAND_bytes((unsigned char *)subscription_key_xor[id], (int) sizeof(subscription_key_xor[id]));
    for (int i= 0; i < IAS_SUBSCRIPTION_KEY_SIZE; i++)
                subscription_key_enc[id][i] = (unsigned char) subscriptionKeyPlainText[i] ^ subscription_key_xor[id][i];
        if ( debug && verbose) {
                eprintf("\n+++ IAS Subscription Key[%d]:\t'%s'\n", id, subscriptionKeyPlainText);
                eprintf("+++ IAS Subscription Key[%d] (Hex):\t%s\n", id, hexstring(subscriptionKeyPlainText, IAS_SUBSCRIPTION_KEY_SIZE));
                eprintf("+++ One-time pad:\t\t\t%s\n", hexstring(subscription_key_xor[id], sizeof(subscription_key_xor[id])));
                eprintf("+++ Encrypted Subscription Key[%d]:\t%s\n\n", id, hexstring(subscription_key_enc[id],sizeof(subscription_key_enc[id])));
                }
    memset(subscriptionKeyPlainText, 0, IAS_SUBSCRIPTION_KEY_SIZE);
    return 1;
}
int IAS_Connection :: setSubscriptionKey ( SubscriptionKeyID id , char * subscriptionKeyPlainText ) { memset ( subscription_key_enc [ id ] , 0 , sizeof ( subscription_key_enc [ id ] ) ) ; memset ( subscription_key_xor [ id ] , 0 , sizeof ( subscription_key_xor [ id ] ) ) ; if ( subscriptionKeyPlainText == NULL || ( strlen ( subscriptionKeyPlainText ) != IAS_SUBSCRIPTION_KEY_SIZE ) || ( id == SubscriptionKeyID :: Last ) ) { if ( debug ) eprintf ( " \n " ) ; return 0 ; } RAND_bytes ( ( unsigned char * ) subscription_key_xor [ id ] , ( int ) sizeof ( subscription_key_xor [ id ] ) ) ; for ( int i = 0 ; i < IAS_SUBSCRIPTION_KEY_SIZE ; i ++ ) subscription_key_enc [ id ] [ i ] = ( unsigned char ) subscriptionKeyPlainText [ i ] ^ subscription_key_xor [ id ] [ i ] ; if ( debug && verbose ) { eprintf ( " \n \t \n " , id , subscriptionKeyPlainText ) ; eprintf ( " \t \n " , id , hexstring ( subscriptionKeyPlainText , IAS_SUBSCRIPTION_KEY_SIZE ) ) ; eprintf ( " \t \t \t \n " , hexstring ( subscription_key_xor [ id ] , sizeof ( subscription_key_xor [ id ] ) ) ) ; eprintf ( " \t \n \n " , id , hexstring ( subscription_key_enc [ id ] , sizeof ( subscription_key_enc [ id ] ) ) ) ; } memset ( subscriptionKeyPlainText , 0 , IAS_SUBSCRIPTION_KEY_SIZE ) ; return 1 ; }
Encrypt the subscription key while its stored in memory
Encrypt the subscription key while its stored in memory
// Create Random one time pad // XOR Subscription Key with One Time Pad to create an encrypted key // zero the original subscription key in memory