]> WPIA git - cassiopeia.git/commitdiff
chg: Move the profile ID in the serial to the back
authorFelix Dörre <felix@dogcraft.de>
Wed, 5 Nov 2014 21:10:27 +0000 (22:10 +0100)
committerBenny Baumann <BenBE@geshi.org>
Fri, 7 Nov 2014 22:53:05 +0000 (23:53 +0100)
This yields (MSB->LSB): <counter> <signer-id> <profile-id> <random>

src/simpleOpensslSigner.cpp

index 8bed9c27553cc6c33e48b41777568c245f091720..eb7d8b9e720232989b8a60c5b0bfc792a50d2fe0 100644 (file)
@@ -97,10 +97,12 @@ std::shared_ptr<BIGNUM> SimpleOpensslSigner::nextSerial( uint16_t profile ) {
 
     std::shared_ptr<unsigned char> data = std::shared_ptr<unsigned char>( ( unsigned char* ) malloc( BN_num_bytes( serial.get() ) + 20 ), free );
     int len = BN_bn2bin( serial.get(), data.get() );
-    data.get()[len] = profile >> 8;
-    data.get()[len + 1] = profile & 0xFF; // profile id
-    data.get()[len + 2] = 0x0;
-    data.get()[len + 3] = 0x0; // signer id
+
+    data.get()[len] = 0x0;
+    data.get()[len + 1] = 0x0; // signer id
+
+    data.get()[len + 2] = profile >> 8;
+    data.get()[len + 3] = profile & 0xFF; // profile id
 
     if( !RAND_bytes( data.get() + len + 4, 16 ) || !BN_add_word( serial.get(), 1 ) ) {
         throw "Big number math failed while calcing serials.";