diff options
author | jsorg71 <jsorg71> | 2006-06-26 00:33:04 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2006-06-26 00:33:04 +0000 |
commit | 4f8e2d60ed0edcf489f4db4eb90460f33c0b70d4 (patch) | |
tree | 7e1db59cf604f2d1a874f78700f0bbec0691b9a3 /uirdesktop/secure.c | |
parent | a2b270e57ab4381f4572ab04338d29f16aec3893 (diff) | |
download | xrdp-proprietary-4f8e2d60ed0edcf489f4db4eb90460f33c0b70d4.tar.gz xrdp-proprietary-4f8e2d60ed0edcf489f4db4eb90460f33c0b70d4.zip |
linux EOL
Diffstat (limited to 'uirdesktop/secure.c')
-rw-r--r-- | uirdesktop/secure.c | 228 |
1 files changed, 114 insertions, 114 deletions
diff --git a/uirdesktop/secure.c b/uirdesktop/secure.c index 90b8eedb..5dba480e 100644 --- a/uirdesktop/secure.c +++ b/uirdesktop/secure.c @@ -24,44 +24,44 @@ //#include <openssl/md5.h> //#include <openssl/sha.h> //#include <openssl/bn.h> -//#include <openssl/x509v3.h>
-
-void *
-ssl_sha1_info_create(void);
-void
-ssl_sha1_info_delete(void * sha1_info);
-void
-ssl_sha1_clear(void * sha1_info);
-void
-ssl_sha1_transform(void * sha1_info, char * data, int len);
-void
-ssl_sha1_complete(void * sha1_info, char * data);
-void *
-ssl_md5_info_create(void);
-void
-ssl_md5_info_delete(void * md5_info);
-void *
-ssl_md5_info_create(void);
-void
-ssl_md5_info_delete(void * md5_info);
-void
-ssl_md5_clear(void * md5_info);
-void
-ssl_md5_transform(void * md5_info, char * data, int len);
-void
-ssl_md5_complete(void * md5_info, char * data);
-void *
-ssl_rc4_info_create(void);
-void
-ssl_rc4_info_delete(void * rc4_info);
-void
-ssl_rc4_set_key(void * rc4_info, char * key, int len);
-void
-ssl_rc4_crypt(void * rc4_info, char * in_data, char * out_data, int len);
-int
-ssl_mod_exp(char* out, int out_len, char* in, int in_len,
- char* mod, int mod_len, char* exp, int exp_len);
-
+//#include <openssl/x509v3.h> + +void * +ssl_sha1_info_create(void); +void +ssl_sha1_info_delete(void * sha1_info); +void +ssl_sha1_clear(void * sha1_info); +void +ssl_sha1_transform(void * sha1_info, char * data, int len); +void +ssl_sha1_complete(void * sha1_info, char * data); +void * +ssl_md5_info_create(void); +void +ssl_md5_info_delete(void * md5_info); +void * +ssl_md5_info_create(void); +void +ssl_md5_info_delete(void * md5_info); +void +ssl_md5_clear(void * md5_info); +void +ssl_md5_transform(void * md5_info, char * data, int len); +void +ssl_md5_complete(void * md5_info, char * data); +void * +ssl_rc4_info_create(void); +void +ssl_rc4_info_delete(void * rc4_info); +void +ssl_rc4_set_key(void * rc4_info, char * key, int len); +void +ssl_rc4_crypt(void * rc4_info, char * in_data, char * out_data, int len); +int +ssl_mod_exp(char* out, int out_len, char* in, int in_len, + char* mod, int mod_len, char* exp, int exp_len); + extern char g_hostname[16]; extern int g_width; extern int g_height; @@ -82,7 +82,7 @@ static int rc4_key_len; static void * rc4_decrypt_key = 0; static void * rc4_encrypt_key = 0; //static RSA *server_public_key; -static void * server_public_key;
+static void * server_public_key; static uint8 sec_sign_key[16]; static uint8 sec_decrypt_key[16]; @@ -123,19 +123,19 @@ sec_hash_48(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2, uint8 salt) for (i = 0; i < 3; i++) { memset(pad, salt + i, i + 1); - sha = ssl_sha1_info_create();
- ssl_sha1_clear(sha);
- ssl_sha1_transform(sha, pad, i + 1);
- ssl_sha1_transform(sha, in, 48);
- ssl_sha1_transform(sha, salt1, 32);
- ssl_sha1_transform(sha, salt2, 32);
- ssl_sha1_complete(sha, shasig);
- ssl_sha1_info_delete(sha);
- md5 = ssl_md5_info_create();
- ssl_md5_clear(md5);
- ssl_md5_transform(md5, in, 48);
- ssl_md5_transform(md5, shasig, 20);
- ssl_md5_complete(md5, out + i * 16);
+ sha = ssl_sha1_info_create(); + ssl_sha1_clear(sha); + ssl_sha1_transform(sha, pad, i + 1); + ssl_sha1_transform(sha, in, 48); + ssl_sha1_transform(sha, salt1, 32); + ssl_sha1_transform(sha, salt2, 32); + ssl_sha1_complete(sha, shasig); + ssl_sha1_info_delete(sha); + md5 = ssl_md5_info_create(); + ssl_md5_clear(md5); + ssl_md5_transform(md5, in, 48); + ssl_md5_transform(md5, shasig, 20); + ssl_md5_complete(md5, out + i * 16); ssl_md5_info_delete(md5); } } @@ -147,13 +147,13 @@ void sec_hash_16(uint8 * out, uint8 * in, uint8 * salt1, uint8 * salt2) { void * md5; -
- md5 = ssl_md5_info_create();
- ssl_md5_clear(md5);
+ + md5 = ssl_md5_info_create(); + ssl_md5_clear(md5); ssl_md5_transform(md5, in, 16); ssl_md5_transform(md5, salt1, 32); - ssl_md5_transform(md5, salt2, 32);
- ssl_md5_complete(md5, out);
+ ssl_md5_transform(md5, salt2, 32); + ssl_md5_complete(md5, out); ssl_md5_info_delete(md5); } @@ -207,15 +207,15 @@ sec_generate_keys(uint8 * client_random, uint8 * server_random, int rc4_key_size memcpy(sec_decrypt_update_key, sec_decrypt_key, 16); memcpy(sec_encrypt_update_key, sec_encrypt_key, 16); - /* Initialise RC4 state arrays */
-
- ssl_rc4_info_delete(rc4_decrypt_key);
- rc4_decrypt_key = ssl_rc4_info_create();
- ssl_rc4_set_key(rc4_decrypt_key, sec_decrypt_key, rc4_key_len);
+ /* Initialise RC4 state arrays */ + + ssl_rc4_info_delete(rc4_decrypt_key); + rc4_decrypt_key = ssl_rc4_info_create(); + ssl_rc4_set_key(rc4_decrypt_key, sec_decrypt_key, rc4_key_len); - ssl_rc4_info_delete(rc4_encrypt_key);
- rc4_encrypt_key = ssl_rc4_info_create();
- ssl_rc4_set_key(rc4_encrypt_key, sec_encrypt_key, rc4_key_len);
+ ssl_rc4_info_delete(rc4_encrypt_key); + rc4_encrypt_key = ssl_rc4_info_create(); + ssl_rc4_set_key(rc4_encrypt_key, sec_encrypt_key, rc4_key_len); } static uint8 pad_54[40] = { @@ -254,23 +254,23 @@ sec_sign(uint8 * signature, int siglen, uint8 * session_key, int keylen, uint8 * buf_out_uint32(lenhdr, datalen); - sha = ssl_sha1_info_create();
- ssl_sha1_clear(sha);
- ssl_sha1_transform(sha, session_key, keylen);
- ssl_sha1_transform(sha, pad_54, 40);
- ssl_sha1_transform(sha, lenhdr, 4);
- ssl_sha1_transform(sha, data, datalen);
- ssl_sha1_complete(sha, shasig);
- ssl_sha1_info_delete(sha);
-
- md5 = ssl_md5_info_create();
- ssl_md5_clear(md5);
- ssl_md5_transform(md5, session_key, keylen);
- ssl_md5_transform(md5, pad_92, 48);
- ssl_md5_transform(md5, shasig, 20);
- ssl_md5_complete(md5, md5sig);
- ssl_md5_info_delete(md5);
-
+ sha = ssl_sha1_info_create(); + ssl_sha1_clear(sha); + ssl_sha1_transform(sha, session_key, keylen); + ssl_sha1_transform(sha, pad_54, 40); + ssl_sha1_transform(sha, lenhdr, 4); + ssl_sha1_transform(sha, data, datalen); + ssl_sha1_complete(sha, shasig); + ssl_sha1_info_delete(sha); + + md5 = ssl_md5_info_create(); + ssl_md5_clear(md5); + ssl_md5_transform(md5, session_key, keylen); + ssl_md5_transform(md5, pad_92, 48); + ssl_md5_transform(md5, shasig, 20); + ssl_md5_complete(md5, md5sig); + ssl_md5_info_delete(md5); + memcpy(signature, md5sig, siglen); } @@ -282,29 +282,29 @@ sec_update(uint8 * key, uint8 * update_key) void * sha; void * md5; void * update; -
- sha = ssl_sha1_info_create();
- ssl_sha1_clear(sha);
- ssl_sha1_transform(sha, update_key, rc4_key_len);
- ssl_sha1_transform(sha, pad_54, 40);
- ssl_sha1_transform(sha, key, rc4_key_len);
- ssl_sha1_complete(sha, shasig);
- ssl_sha1_info_delete(sha);
- - md5 = ssl_md5_info_create();
- ssl_md5_clear(md5);
- ssl_md5_transform(md5, update_key, rc4_key_len);
- ssl_md5_transform(md5, pad_92, 48);
- ssl_md5_transform(md5, shasig, 20);
- ssl_md5_complete(md5, key);
- ssl_md5_info_delete(md5);
- -
- update = ssl_rc4_info_create();
- ssl_rc4_set_key(update, key, rc4_key_len);
- ssl_rc4_crypt(update, key, key, rc4_key_len);
- ssl_rc4_info_delete(update);
-
+ + sha = ssl_sha1_info_create(); + ssl_sha1_clear(sha); + ssl_sha1_transform(sha, update_key, rc4_key_len); + ssl_sha1_transform(sha, pad_54, 40); + ssl_sha1_transform(sha, key, rc4_key_len); + ssl_sha1_complete(sha, shasig); + ssl_sha1_info_delete(sha); + + md5 = ssl_md5_info_create(); + ssl_md5_clear(md5); + ssl_md5_transform(md5, update_key, rc4_key_len); + ssl_md5_transform(md5, pad_92, 48); + ssl_md5_transform(md5, shasig, 20); + ssl_md5_complete(md5, key); + ssl_md5_info_delete(md5); + + + update = ssl_rc4_info_create(); + ssl_rc4_set_key(update, key, rc4_key_len); + ssl_rc4_crypt(update, key, key, rc4_key_len); + ssl_rc4_info_delete(update); + if (rc4_key_len == 8) sec_make_40bit(key); } @@ -315,7 +315,7 @@ sec_encrypt(uint8 * data, int length) { if (sec_encrypt_use_count == 4096) { - sec_update(sec_encrypt_key, sec_encrypt_update_key);
+ sec_update(sec_encrypt_key, sec_encrypt_update_key); ssl_rc4_set_key(rc4_encrypt_key, sec_encrypt_key, rc4_key_len); sec_encrypt_use_count = 0; } @@ -330,10 +330,10 @@ sec_decrypt(uint8 * data, int length) if (sec_decrypt_use_count == 4096) { sec_update(sec_decrypt_key, sec_decrypt_update_key); - ssl_rc4_set_key(rc4_decrypt_key, sec_decrypt_key, rc4_key_len);
+ ssl_rc4_set_key(rc4_decrypt_key, sec_decrypt_key, rc4_key_len); sec_decrypt_use_count = 0; } - ssl_rc4_crypt(rc4_decrypt_key, data, data, length);
+ ssl_rc4_crypt(rc4_decrypt_key, data, data, length); sec_decrypt_use_count++; } @@ -354,8 +354,8 @@ reverse(uint8 * p, int len) /* Perform an RSA public key encryption operation */ static void sec_rsa_encrypt(uint8 * out, uint8 * in, int len, uint8 * modulus, uint8 * exponent) -{
- ssl_mod_exp(out, 64, in, 32, modulus, 64, exponent, 4);
+{ + ssl_mod_exp(out, 64, in, 32, modulus, 64, exponent, 4); /* BN_CTX *ctx; BIGNUM mod, exp, x, y; @@ -578,7 +578,7 @@ sec_parse_public_key(STREAM s, uint8 ** modulus, uint8 ** exponent) return s_check(s); } -
+ /* Parse a crypto information structure */ static BOOL sec_parse_crypt_info(STREAM s, uint32 * rc4_key_size, @@ -647,7 +647,7 @@ sec_parse_crypt_info(STREAM s, uint32 * rc4_key_size, } } else - {
+ { #if 0 uint32 certcount; @@ -737,7 +737,7 @@ sec_parse_crypt_info(STREAM s, uint32 * rc4_key_size, } X509_free(server_cert); return True; /* There's some garbage here we don't care about */ -#endif
+#endif } return s_check_end(s); } @@ -783,7 +783,7 @@ sec_process_crypt_info(STREAM s) reverse(sec_crypted_random, SEC_MODULUS_SIZE); RSA_free(server_public_key); - server_public_key = NULL;
+ server_public_key = NULL; #endif } else |