Comparing version 1.3.19 to 1.3.23
@@ -808,2 +808,3 @@ /* | ||
default: | ||
; | ||
} | ||
@@ -839,3 +840,3 @@ | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -864,3 +865,3 @@ break; | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -883,3 +884,3 @@ break; | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -901,3 +902,3 @@ break; | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -919,3 +920,3 @@ break; | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -935,3 +936,3 @@ break; | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -951,3 +952,3 @@ break; | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -970,3 +971,3 @@ break; | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -1007,4 +1008,3 @@ break; | ||
// #endregion | ||
default: | ||
default:; | ||
} | ||
@@ -1260,3 +1260,4 @@ | ||
result = { | ||
name: "P-256" | ||
name: "P-256", | ||
size: 32 | ||
}; | ||
@@ -1266,3 +1267,4 @@ break; | ||
result = { | ||
name: "P-384" | ||
name: "P-384", | ||
size: 48 | ||
}; | ||
@@ -1272,8 +1274,8 @@ break; | ||
result = { | ||
name: "P-521" | ||
name: "P-521", | ||
size: 66 | ||
}; | ||
break; | ||
// #endregion | ||
default: | ||
default:; | ||
} | ||
@@ -1333,3 +1335,3 @@ | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -1343,5 +1345,2 @@ | ||
{ | ||
/// <summary>Create CMS ECDSA signature from WebCrypto ECDSA signature</summary> | ||
/// <param name="signatureBuffer" type="ArrayBuffer">WebCrypto result of "sign" function</param> | ||
// #region Initial check for correct length | ||
@@ -1360,2 +1359,3 @@ if((signatureBuffer.byteLength % 2) != 0) | ||
var r_view = new Uint8Array(r_buffer); | ||
r_view.set(new Uint8Array(signatureBuffer, 0, length)); | ||
var r_corrected_buffer; | ||
@@ -1366,2 +1366,3 @@ var r_corrected_view; | ||
var s_view = new Uint8Array(s_buffer); | ||
s_view.set(new Uint8Array(signatureBuffer, length, length)); | ||
var s_corrected_buffer; | ||
@@ -1372,43 +1373,46 @@ var s_corrected_view; | ||
// #region Get "r" part of ECDSA signature | ||
for(; i < length; i++) | ||
r_view[i] = signatureView[i]; | ||
if(r_view[0] & 0x80) | ||
switch(true) | ||
{ | ||
r_corrected_buffer = new ArrayBuffer(length + 1); | ||
r_corrected_view = new Uint8Array(r_corrected_buffer); | ||
case ((r_view[0] & 0x80) !== 0): | ||
r_corrected_buffer = new ArrayBuffer(length + 1); | ||
r_corrected_view = new Uint8Array(r_corrected_buffer); | ||
r_corrected_view[0] = 0x00; | ||
r_corrected_view[0] = 0x00; | ||
for(var j = 0; j < length; j++) | ||
r_corrected_view[j + 1] = r_view[j]; | ||
r_corrected_view.set(r_view, 1); | ||
break; | ||
case ((r_view[0] === 0x00) && ((r_view[1] & 0x80) === 0)): | ||
r_corrected_buffer = new ArrayBuffer(length - 1); | ||
r_corrected_view = new Uint8Array(r_corrected_buffer); | ||
r_corrected_view.set(new Uint8Array(signatureBuffer, 1, length - 1)); | ||
break; | ||
default: | ||
r_corrected_buffer = r_buffer; | ||
r_corrected_view = r_view; | ||
} | ||
else | ||
{ | ||
r_corrected_buffer = r_buffer; | ||
r_corrected_view = r_view; | ||
} | ||
// #endregion | ||
// #endregion | ||
// #region Get "s" part of ECDSA signature | ||
for(; i < signatureBuffer.byteLength; i++) | ||
s_view[i - length] = signatureView[i]; | ||
switch(true) | ||
{ | ||
case ((s_view[0] & 0x80) !== 0): | ||
s_corrected_buffer = new ArrayBuffer(length + 1); | ||
s_corrected_view = new Uint8Array(s_corrected_buffer); | ||
s_corrected_view[0] = 0x00; | ||
if(s_view[0] & 0x80) | ||
{ | ||
s_corrected_buffer = new ArrayBuffer(length + 1); | ||
s_corrected_view = new Uint8Array(s_corrected_buffer); | ||
s_corrected_view.set(s_view, 1); | ||
break; | ||
case ((s_view[0] === 0x00) && ((s_view[1] & 0x80) === 0)): | ||
s_corrected_buffer = new ArrayBuffer(length - 1); | ||
s_corrected_view = new Uint8Array(s_corrected_buffer); | ||
s_corrected_view[0] = 0x00; | ||
for(var j = 0; j < length; j++) | ||
s_corrected_view[j + 1] = s_view[j]; | ||
s_corrected_view.set(new Uint8Array(signatureBuffer, 1, length - 1)); | ||
break; | ||
default: | ||
s_corrected_buffer = s_buffer; | ||
s_corrected_view = s_view; | ||
} | ||
else | ||
{ | ||
s_corrected_buffer = s_buffer; | ||
s_corrected_view = s_view; | ||
} | ||
// #endregion | ||
// #endregion | ||
@@ -1433,3 +1437,3 @@ // #region Create ASN.1 structure of CMS ECDSA signature | ||
return asn1.toBER(false); | ||
}; | ||
} | ||
//************************************************************************************** | ||
@@ -1439,48 +1443,61 @@ in_window.org.pkijs.createECDSASignatureFromCMS = | ||
{ | ||
/// <summary>Create a single ArrayBuffer from CMS ECDSA signature</summary> | ||
/// <param name="cmsSignature" type="in_window.org.pkijs.asn1.SEQUENCE">ASN.1 SEQUENCE contains CMS ECDSA signature</param> | ||
// #region Initial variables | ||
var length = 0; | ||
var sBuffer; | ||
var rBuffer; | ||
// #endregion | ||
var r_start = 0; | ||
var s_start = 0; | ||
// #region Check input variables | ||
if((cmsSignature instanceof in_window.org.pkijs.asn1.SEQUENCE) === false) | ||
return new ArrayBuffer(0); | ||
var r_length = cmsSignature.value_block.value[0].value_block.value_hex.byteLength; | ||
var s_length = cmsSignature.value_block.value[1].value_block.value_hex.byteLength; | ||
if(cmsSignature.value_block.value.length !== 2) | ||
return new ArrayBuffer(0); | ||
if((cmsSignature.value_block.value[0] instanceof in_window.org.pkijs.asn1.INTEGER) === false) | ||
return new ArrayBuffer(0); | ||
if((cmsSignature.value_block.value[1] instanceof in_window.org.pkijs.asn1.INTEGER) === false) | ||
return new ArrayBuffer(0); | ||
// #endregion | ||
// #region Get length of final "ArrayBuffer" | ||
var r_view = new Uint8Array(cmsSignature.value_block.value[0].value_block.value_hex); | ||
if((r_view[0] === 0x00) && (r_view[1] & 0x80)) | ||
// #region Aux functions | ||
function transformINTEGER(integer) | ||
{ | ||
length = r_length - 1; | ||
r_start = 1; | ||
} | ||
else | ||
length = r_length; | ||
var view = new Uint8Array(integer.value_block.value_hex); | ||
var s_view = new Uint8Array(cmsSignature.value_block.value[1].value_block.value_hex); | ||
if((s_view[0] === 0x00) && (s_view[1] & 0x80)) | ||
{ | ||
length += s_length - 1; | ||
s_start = 1; | ||
switch(integer.value_block.value_hex.byteLength) | ||
{ | ||
case 32: | ||
case 48: | ||
case 66: | ||
return integer.value_block.value_hex; | ||
break; | ||
case 33: | ||
case 49: | ||
case 67: | ||
return (view.slice(1)).buffer; | ||
break; | ||
case 31: | ||
case 47: | ||
case 65: | ||
{ | ||
var updatedBuffer = new ArrayBuffer(integer.value_block.value_hex.byteLength + 1); | ||
var updatedView = new Uint8Array(updatedBuffer); | ||
updatedView.set(view, 1); | ||
return updatedBuffer; | ||
} | ||
break; | ||
default: | ||
return new ArrayBuffer(0); | ||
} | ||
} | ||
else | ||
length += s_length; | ||
// #endregion | ||
// #region Copy values from CMS ECDSA signature | ||
var result = new ArrayBuffer(length); | ||
var result_view = new Uint8Array(result); | ||
rBuffer = transformINTEGER(cmsSignature.value_block.value[0]); | ||
sBuffer = transformINTEGER(cmsSignature.value_block.value[1]); | ||
for(var i = r_start; i < r_length; i++) | ||
result_view[i - r_start] = r_view[i]; | ||
for(var i = s_start; i < s_length; i++) | ||
result_view[i - s_start + r_length - r_start] = s_view[i]; | ||
// #endregion | ||
return result; | ||
}; | ||
return in_window.org.pkijs.concat_buffers(rBuffer, sBuffer); | ||
} | ||
//************************************************************************************** | ||
@@ -1509,3 +1526,3 @@ in_window.org.pkijs.getEncryptionAlgorithm = | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -1525,6 +1542,6 @@ break; | ||
break; | ||
default: | ||
default:; | ||
} | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -1555,3 +1572,3 @@ | ||
break; | ||
default: | ||
default:; | ||
} | ||
@@ -1558,0 +1575,0 @@ |
@@ -8,3 +8,3 @@ { | ||
"description": "Public Key Infrastructure (PKI) is the basis of how identity and key management is performed on the web today. PKIjs is a pure JavaScript library implementing the formats that are used in PKI applications. It is built on WebCrypto and aspires to make it possible to build native web applications that utilize X.509 and the related formats on the web without plug-ins", | ||
"version": "1.3.19", | ||
"version": "1.3.23", | ||
"repository": { | ||
@@ -11,0 +11,0 @@ "type": "git", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3898301
68088