Skip to content

Commit

Permalink
fix whitespacing issue in ES6 strings for rsaPublicKeyPem in aadutils…
Browse files Browse the repository at this point in the history
….js. fixes AzureAD#117
  • Loading branch information
dhodgin committed Jun 10, 2016
1 parent f4afd5b commit 5b960a8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/aadutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,21 @@ exports.rsaPublicKeyPem = (modulusB64, exponentB64) => {

const encodedModlen = encodeLengthHex(modlen);
const encodedExplen = encodeLengthHex(explen);
const encodedPubkey = `30
${encodeLengthHex(
modlen +
explen +
encodedModlen.length / 2 +
encodedExplen.length / 2 + 2
)}
02${encodedModlen}${modulusHex}
02${encodedExplen}${exponentHex}`;
const encodedPubkey = '30' +
encodeLengthHex(
modlen +
explen +
encodedModlen.length/2 +
encodedExplen.length/2 + 2
) +
'02' + encodedModlen + modulusHex +
'02' + encodedExplen + exponentHex;

const derB64 = new Buffer(encodedPubkey, 'hex').toString('base64');

const pem = `-----BEGIN RSA PUBLIC KEY-----\n
${derB64.match(/.{1,64}/g).join('\n')}
\n-----END RSA PUBLIC KEY-----\n`;
let pem = `-----BEGIN RSA PUBLIC KEY-----\n`;
pem += `${derB64.match(/.{1,64}/g).join('\n')}`
pem += `\n-----END RSA PUBLIC KEY-----\n`;

return pem;
};

0 comments on commit 5b960a8

Please sign in to comment.