Changeset 4022
- Timestamp:
- 11/30/10 13:47:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-cccam.c
r4021 r4022 108 108 } 109 109 110 void cc_c w_crypt_cmd0c(struct s_client *cl, uint8 *cws) {110 void cc_crypt_cmd0c(struct s_client *cl, uint8 *buf, int len) { 111 111 struct cc_data *cc = cl->cc; 112 uint8 out[16];112 uint8 *out = malloc(len); 113 113 114 114 switch (cc->cmd0c_mode) { 115 115 case MODE_CMD_0x0C_NONE: { // none additional encryption 116 memcpy(out, buf, len); 116 117 break; 117 118 } 118 119 case MODE_CMD_0x0C_RC6 : { //RC6 119 rc6_block_decrypt((unsigned int *) cws, 120 (unsigned int *) &out, cc->cmd0c_RC6_cryptkey); 121 memcpy(cws, &out, 16); 120 //rc6_block_decrypt(buf, out, cc->cmd0c_RC6_cryptkey); // TODO RC6 122 121 break; 123 122 } 124 123 case MODE_CMD_0x0C_RC4: { // RC4 125 cc_rc4_crypt(&cc->cmd0c_cryptkey, cws, 16, ENCRYPT); 124 cc_rc4_crypt(&cc->cmd0c_cryptkey, buf, len, ENCRYPT); 125 memcpy(out, buf, len); 126 126 break; 127 127 } 128 128 case MODE_CMD_0x0C_CC_CRYPT: { // cc_crypt 129 cc_crypt(&cc->cmd0c_cryptkey, cws, 16, DECRYPT); 130 cws[0] ^= 0xF0; 131 cws[15] ^= 0xF0; 129 cc_crypt(&cc->cmd0c_cryptkey, buf, len, DECRYPT); 130 memcpy(out, buf, len); 132 131 break; 133 132 } 134 133 case MODE_CMD_0x0C_AES: { // AES 135 AES_decrypt((unsigned char *) cws, 136 (unsigned char *) &out, &cc->cmd0c_AES_key); 137 memcpy(cws, &out, 16); 134 int i; 135 for (i = 0; i<len / 16; i++) 136 AES_decrypt((unsigned char *) buf + i * 8, 137 (unsigned char *) out + i * 8, &cc->cmd0c_AES_key); 138 138 break; 139 139 } 140 140 case MODE_CMD_0x0C_IDEA : { //IDEA 141 uint8 cws_in[8];142 141 int i; 143 142 144 memcpy(&cws_in, cws, 8); 145 idea_ecb_encrypt(cws_in, out, &cc->cmd0c_IDEA_dkey); 146 memcpy(&cws_in, cws + 8, 8); 147 idea_ecb_encrypt(cws_in, out + 8, &cc->cmd0c_IDEA_dkey); 148 149 //final cws[8-15]: 143 idea_ecb_encrypt(buf, out, &cc->cmd0c_IDEA_dkey); 144 idea_ecb_encrypt(buf + 8, out + 8, &cc->cmd0c_IDEA_dkey); 145 150 146 for (i = 8; i < 16; i++) 151 out[i] ^= cws[i-8]; 152 153 memcpy(cws, &out, 16); 147 out[i] ^= buf[i-8]; 148 154 149 break; 155 } 156 } 150 } 151 } 152 memcpy(buf, out, len); 153 free(out); 157 154 } 158 155 … … 2135 2132 if (!cc->extended_mode) { 2136 2133 cc_cw_crypt(cl, buf + 4, card->id); 2137 cc_c w_crypt_cmd0c(cl, buf + 4);2134 cc_crypt_cmd0c(cl, buf + 4, 16); 2138 2135 } 2139 2136 … … 2279 2276 else //reader 2280 2277 { 2281 // by Project:Keynation 2278 // by Project:Keynation + Oscam team 2279 cc_crypt_cmd0c(cl, data, len); 2280 2282 2281 uint8 CMD_0x0C_Command = data[0]; 2283 2282
Note:
See TracChangeset
for help on using the changeset viewer.