Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vereign Client Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
Vereign Client Library
Commits
4cd3745f
Commit
4cd3745f
authored
5 years ago
by
Zdravko Iliev
Browse files
Options
Downloads
Patches
Plain Diff
debug info public key
parent
0b9643d4
No related branches found
No related tags found
1 merge request
!83
Exchange 2016 support
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
javascript/src/utilities/signingUtilities.js
+35
-32
35 additions, 32 deletions
javascript/src/utilities/signingUtilities.js
with
35 additions
and
32 deletions
javascript/src/utilities/signingUtilities.js
+
35
−
32
View file @
4cd3745f
...
...
@@ -314,9 +314,9 @@ function fixPkijsRDN() {
//region Decode stored TBS value
if
(
this
.
valueBeforeDecode
.
byteLength
===
0
)
// No stored encoded array, create "from scratch"
{
return
(
new
asn1js
.
Sequence
({
return
new
asn1js
.
Sequence
({
value
:
Array
.
from
(
this
.
typesAndValues
,
element
=>
new
asn1js
.
Set
({
value
:
[
element
.
toSchema
()]}))
})
)
;
});
}
const
asn1
=
asn1js
.
fromBER
(
this
.
valueBeforeDecode
);
...
...
@@ -330,7 +330,6 @@ function fixPkijsRDN() {
//*********************************************************************************
function
createCertificate
(
certData
,
issuerData
=
null
)
{
if
(
typeof
certData
===
"
undefined
"
||
certData
===
null
)
{
return
Promise
.
reject
(
"
No Certificate data provided
"
);
}
...
...
@@ -596,9 +595,9 @@ function createCertificate(certData, issuerData = null) {
const
keyUsageBuffer
=
new
ArrayBuffer
(
1
);
const
keyUsageBitView
=
new
Uint8Array
(
keyUsageBuffer
);
keyUsageBitView
[
0
]
=
!!
certData
.
isCA
?
KEY_USAGE_CertificateAuthority
:
KEY_USAGE_LeafCertificate
;
keyUsageBitView
[
0
]
=
certData
.
isCA
?
KEY_USAGE_CertificateAuthority
:
KEY_USAGE_LeafCertificate
;
// noinspection JSUnresolvedFunction
const
keyUsage
=
new
asn1js
.
BitString
({
valueHex
:
keyUsageBuffer
});
...
...
@@ -625,7 +624,7 @@ function createCertificate(certData, issuerData = null) {
keyPurposes
.
push
(
OID_ID_PKIX_TimeStamping
);
const
extKeyUsage
=
new
pkijs
.
ExtKeyUsage
({
keyPurposes
:
keyPurposes
keyPurposes
});
certificate
.
extensions
.
push
(
...
...
@@ -662,7 +661,7 @@ function createCertificate(certData, issuerData = null) {
}
const
subjAltNames
=
new
pkijs
.
GeneralNames
({
names
:
names
names
});
certificate
.
extensions
.
push
(
...
...
@@ -739,15 +738,20 @@ function createCertificate(certData, issuerData = null) {
//region Signing final certificate
sequence
=
sequence
.
then
(
()
=>
{
let
signerKey
=
issuerData
&&
issuerData
.
privateKey
?
issuerData
.
privateKey
:
privateKey
;
const
signerKey
=
issuerData
&&
issuerData
.
privateKey
?
issuerData
.
privateKey
:
privateKey
;
console
.
log
({
signerKey
});
console
.
log
({
certData
});
console
.
log
({
defaultAlgorithms
});
return
certificate
.
sign
(
signerKey
,
certData
.
algorithms
&&
certData
.
algorithms
.
hashAlg
?
certData
.
algorithms
.
hashAlg
:
defaultAlgorithms
.
hashAlg
certData
.
algorithms
&&
certData
.
algorithms
.
hashAlg
?
certData
.
algorithms
.
hashAlg
:
defaultAlgorithms
.
hashAlg
);
},
error
=>
Promise
.
reject
(
`Error during exporting public key:
${
error
}
`
)
...
...
@@ -791,11 +795,11 @@ function createCertificate(certData, issuerData = null) {
return
sequence
.
then
(()
=>
{
const
result
=
{
certificate
:
certificate
,
certificate
,
certificatePEM
:
encodePEM
(
certificateBuffer
,
"
CERTIFICATE
"
),
publicKey
:
publicKey
,
publicKey
,
publicKeyPEM
:
encodePEM
(
publicKeyBuffer
,
"
PUBLIC KEY
"
),
privateKey
:
privateKey
,
privateKey
,
privateKeyPEM
:
encodePEM
(
privateKeyBuffer
,
"
PRIVATE KEY
"
)
};
return
result
;
...
...
@@ -1042,7 +1046,7 @@ Vereign - Authentic Communication
const
hashAlg
=
"
SHA-256
"
;
let
cmsSignedSimpl
;
le
t
mimeHeadersTitles
=
[
cons
t
mimeHeadersTitles
=
[
"
Content-Type
"
,
"
Content-Transfer-Encoding
"
,
"
Content-ID
"
,
...
...
@@ -1055,26 +1059,26 @@ Vereign - Authentic Communication
mime
=
mime
.
replace
(
newline
,
"
\r\n
"
);
let
newHeaderLines
=
""
;
le
t
headersEnd
=
mime
.
indexOf
(
"
\r\n\r\n
"
);
//the first empty line
cons
t
headersEnd
=
mime
.
indexOf
(
"
\r\n\r\n
"
);
//the first empty line
if
(
headersEnd
<
0
&&
mime
.
startsWith
(
"
\r\n
"
))
{
mime
=
mime
.
substring
(
2
);
//should not happen
}
else
if
(
headersEnd
>=
0
)
{
le
t
mimeHeaders
=
{};
le
t
mimeBody
=
mime
.
substring
(
headersEnd
+
4
);
cons
t
mimeHeaders
=
{};
cons
t
mimeBody
=
mime
.
substring
(
headersEnd
+
4
);
le
t
mimeHeadersStr
=
mime
.
substring
(
0
,
headersEnd
);
cons
t
mimeHeadersStr
=
mime
.
substring
(
0
,
headersEnd
);
le
t
headers
=
libmime
.
decodeHeaders
(
mimeHeadersStr
);
cons
t
headers
=
libmime
.
decodeHeaders
(
mimeHeadersStr
);
for
(
let
i
=
0
;
i
<
mimeHeadersTitles
.
length
;
i
++
)
{
le
t
key
=
mimeHeadersTitles
[
i
].
toLowerCase
();
cons
t
key
=
mimeHeadersTitles
[
i
].
toLowerCase
();
if
(
key
in
headers
)
{
mimeHeaders
[
key
]
=
headers
[
key
];
delete
headers
[
key
];
}
}
for
(
le
t
key
in
headers
)
{
for
(
cons
t
key
in
headers
)
{
if
(
!
(
key
===
""
||
key
===
"
MIME-Version
"
.
toLowerCase
()))
{
//we have MIME-Version in the template
newHeaderLines
+=
capitalizeHeader
(
key
)
+
"
:
"
+
headers
[
key
]
+
"
\r\n
"
;
...
...
@@ -1082,7 +1086,7 @@ Vereign - Authentic Communication
}
let
newMimeHeaderLines
=
""
;
for
(
le
t
key
in
mimeHeaders
)
{
for
(
cons
t
key
in
mimeHeaders
)
{
if
(
!
(
key
===
""
))
{
newMimeHeaderLines
+=
capitalizeHeader
(
key
)
+
"
:
"
+
mimeHeaders
[
key
]
+
"
\r\n
"
;
...
...
@@ -1096,7 +1100,7 @@ Vereign - Authentic Communication
mime
=
newMimeHeaderLines
+
"
\r\n
"
+
mimeBody
;
}
le
t
dataBuffer
=
Buffer
.
from
(
mime
,
"
utf-8
"
);
cons
t
dataBuffer
=
Buffer
.
from
(
mime
,
"
utf-8
"
);
let
sequence
=
Promise
.
resolve
();
...
...
@@ -1235,8 +1239,8 @@ Vereign - Authentic Communication
//endregion
sequence
=
sequence
.
then
(
cmsSignedBuffer
=>
{
le
t
signature
=
arrayBufferToBase64Formatted
(
cmsSignedBuffer
);
le
t
boundary
=
makeBoundary
();
cons
t
signature
=
arrayBufferToBase64Formatted
(
cmsSignedBuffer
);
cons
t
boundary
=
makeBoundary
();
template
=
template
.
replace
(
/{{boundary}}/g
,
boundary
);
template
=
template
.
replace
(
"
{{signature}}
"
,
signature
);
...
...
@@ -1278,7 +1282,7 @@ function capitalizeHeader(string) {
}
function
makeBoundary
()
{
le
t
len
=
20
+
Math
.
random
()
*
20
;
cons
t
len
=
20
+
Math
.
random
()
*
20
;
return
"
W0RyLiBEYW15YW4gTWl0ZXZd--
"
+
makeid
(
len
);
}
...
...
@@ -1472,7 +1476,6 @@ export const verifySMIME = (smimeString, rootCaPem) => {
};
export
class
ImageData
{
/**
* Constructor for ImageData class
* @param {Object} [parameters] Object in format
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment