From b9093a80fe9374f5750ebe40b3c6490f62561da6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Wed, 5 Nov 2014 22:10:27 +0100 Subject: [PATCH] chg: Move the profile ID in the serial to the back This yields (MSB->LSB): --- src/simpleOpensslSigner.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/simpleOpensslSigner.cpp b/src/simpleOpensslSigner.cpp index 8bed9c2..eb7d8b9 100644 --- a/src/simpleOpensslSigner.cpp +++ b/src/simpleOpensslSigner.cpp @@ -97,10 +97,12 @@ std::shared_ptr SimpleOpensslSigner::nextSerial( uint16_t profile ) { std::shared_ptr data = std::shared_ptr( ( 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."; -- 2.39.2