User Tools

Site Tools


devicesal

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
devicesal [2009/05/07 09:38] – document "ocmmod" marcusdevicesal [2009/05/27 12:31] – example for ssatrans marcus
Line 1: Line 1:
 +Missing Info:
 +
 +<code>
 +
 +Dict 0xfc - contains an unknown 8 byte key, used in dev_0xd8, dev_0xd9.
 +
 +</code>
 +
 Native modules: Native modules:
 <code> <code>
Line 94: Line 102:
  
 // Some decrypt function. // Some decrypt function.
 +// KEYBLOB seems to be 16 byte in practice.
 any_t any_t
-dev_0xd8 (blob_t data1, blob_t data2)+dev_0xd8 (blob_t ciphertext, blob_t keyblob)
 { {
-  blob_t data3 data2 XOR concat (dict[0xfc], dict[0xfc]); +  blob_t key keyblob XOR concat (dict[0xfc], dict[0xfc]); 
-  dict[0xdb] = data3;+  // Side-effect. 
 +  dict[0xdb] = key;
  
-  blob_t shasum = SHA1 (data3[0..1f]); +  blob_t hashed_key = SHA1 (key[0..14]); 
-  blob_t iv shasum[0..7]; +  blob_t des_iv hashed_key[0..7]; 
-  blob_t key shasum[8..15]+  blob_t des_key hashed_key[8..15]
  
-  blob_t dec_data1 = DES_CBC_Decrypt (data1ivkey, 0xd8_DESDecrypt);+  blob_t data = DES_CBC_Decrypt (ciphertextdes_ivdes_key, 0xd8_DESDecrypt);
    
   // Decrypt with ocmmod cipher.   // Decrypt with ocmmod cipher.
-  int len = blob_length (dec_data);+  int len = blob_length (data);
   // Round up to multiple of 8.   // Round up to multiple of 8.
   len = (len + 7) / 8 * 8;   len = (len + 7) / 8 * 8;
-  blob_t out = repeat_nul (len); +  blob_t plaintext = repeat_nul (len); 
-  out = native::ocmmod (dec_data1outshasum, len, 1);+  plaintext = native::ocmmod (dataplaintexthashed_key, len, 1);
  
-  return decode_asn1 (out);+  // Return deserialized object. 
 +  return decode_asn1 (plaintext)
 +
 + 
 + 
 +// Some encrypt function. 
 +// KEYBLOB seems to be 16 byte in practice. 
 +blob_t 
 +dev_0xd9 (any_t plainobj, blob_t keyblob) 
 +
 +  blob_t key = keyblob XOR concat (dict[0xfc], dict[0xfc]); 
 +  // Side-effect. 
 +  dict[0xdb] = key; 
 + 
 +  // Serialization. 
 +  plaintext = encode_asn1 (plaintext); 
 + 
 +  // Encrypt with ocmmod cipher. 
 +  int len = blob_length (data); 
 +  // Round up to multiple of 8. 
 +  len = (len + 7) / 8 * 8; 
 +  blob_t data = repeat_nul (len); 
 +  blob_t hashed_key = SHA1 (key[0..14]); 
 +  data = native::ocmmod (plaintext, data, hashed_key, len, 0); 
 + 
 +  // Encrypt DES. 
 +  blob_t des_iv = hashed_key[0..7]; 
 +  blob_t des_key = hashed_key[8..15] 
 +  blob_t ciphertext = DES_CBC_Decrypt (data, des_iv, des_key, 0xd7_DESEncrypt); 
 + 
 +  return ciphertext;
 } }
 </code> </code>
  
 +NOT part of device.sal, but for lack of a better place, here an example of SsaTrans on updater.ocm:
 +
 +<code>
 +$ SsaTrans updater.ocm
 +BCSeedRand63 (1, "j5\162\GS\140<,\f");
 +BCSetCryptTable ("L\225\164\152\DC1\RSD?\216f\198!\196\154\154\201\195b \192l^V\176r\245\151*\245[[\DC1\NULV#"...);
 +v_39 = BCNewBlob (8);
 +v_41 = BCDES_SetKey ("\188k\180(\150\EOT,\138");
 +arg_0 = Unknown
 +v_43 = BCDES_CBC BCDDecrypt (arg_0, v_39, v_41, "\216");
 +v_44 = BCBlobLength (v_43);
 +v_46 = BCBlobLength ("<!--omg certificated-->");
 +v_49 = BCSubBlob (v_43, v_44 - v_46, -1);
 +v_51 = BCCompareBlob (v_49, "<!--omg certificated-->");
 +if (v_51 == 0) [1 -> 1]
 +  {
 +    return [v_43, 1];
 +  }
 +else [1 -> 1]
 +  {
 +    return [0];
 +  }
 +v_56 = BCIfElse (v_43);
 +v_57 = BCSerialize (v_56);
 +return v_57;
 +</code>
devicesal.txt · Last modified: 2009/06/02 01:44 by marcus

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki