Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Hexang 息壤平台
persona
Commits
0733ed04
Commit
0733ed04
authored
13 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
use cert chain verifier from jwcrypto
parent
53419717
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
browserid/lib/ca.js
+8
-16
8 additions, 16 deletions
browserid/lib/ca.js
browserid/tests/ca-test.js
+4
-5
4 additions, 5 deletions
browserid/tests/ca-test.js
browserid/tests/cert-emails-test.js
+13
-1
13 additions, 1 deletion
browserid/tests/cert-emails-test.js
lib/jwcrypto
+1
-1
1 addition, 1 deletion
lib/jwcrypto
with
26 additions
and
23 deletions
browserid/lib/ca.js
+
8
−
16
View file @
0733ed04
...
...
@@ -93,22 +93,14 @@ function certify(email, publicKey, expiration) {
}
function
verifyChain
(
certChain
)
{
// the certChain is expected to be ordered
// first cert signed root, next cert signed by first, ...
// returns the last certified public key
var
currentPublicKey
=
PUBLIC_KEY
;
for
(
var
i
=
0
;
i
<
certChain
.
length
;
i
++
)
{
var
cert
=
certChain
[
i
];
if
(
!
cert
.
verify
(
currentPublicKey
))
{
return
false
;
}
// the public key for the next verification is..
currentPublicKey
=
cert
.
pk
;
}
// return last certified public key
return
currentPublicKey
;
// raw certs
return
jwcert
.
JWCert
.
verifyChain
(
certChain
,
function
(
issuer
)
{
// for now we only do browserid.org issued keys
if
(
issuer
!=
"
browserid2.org
"
)
return
null
;
return
PUBLIC_KEY
;
});
}
// exports, not the key stuff
...
...
This diff is collapsed.
Click to expand it.
browserid/tests/ca-test.js
+
4
−
5
View file @
0733ed04
...
...
@@ -61,13 +61,12 @@ var email_addr = "foo@foo.com";
suite
.
addBatch
({
"
certify a public key
"
:
{
topic
:
ca
.
certify
(
email_addr
,
kp
.
publicKey
),
"
parses
"
:
function
(
r
,
err
)
{
var
cert
=
ca
.
parseCert
(
r
);
"
parses
"
:
function
(
cert_raw
,
err
)
{
var
cert
=
ca
.
parseCert
(
cert_raw
);
assert
.
notEqual
(
cert
,
null
);
},
"
verifies
"
:
function
(
r
,
err
)
{
var
cert
=
ca
.
parseCert
(
r
);
assert
.
isTrue
(
ca
.
verifyChain
([
cert
]).
equals
(
kp
.
publicKey
));
"
verifies
"
:
function
(
cert_raw
,
err
)
{
assert
.
isTrue
(
kp
.
publicKey
.
equals
(
ca
.
verifyChain
([
cert_raw
])));
}
},
"
certify a chain of keys
"
:
{
...
...
This diff is collapsed.
Click to expand it.
browserid/tests/cert-emails-test.js
+
13
−
1
View file @
0733ed04
...
...
@@ -148,7 +148,19 @@ suite.addBatch({
assert
.
equal
(
full_assertion
.
assertion
.
split
(
"
.
"
).
length
,
3
);
},
"
assertion verifies
"
:
{
topic
:
function
(
full_assertion
)
{
return
wsapi
.
get
(
cert_key_url
,
{
assertion
:
full_assertion
,
audience
:
"
rp.com
"
})();},
topic
:
function
(
full_assertion
)
{
// check that the assertion is verified by the public key in the chain cert
var
cert_chain
=
[];
for
(
var
i
=
0
;
i
<
full_assertion
.
certificates
.
length
;
i
++
)
{
var
cert
=
new
jwcert
.
JWCert
();
cert
.
parse
(
full_assertion
.
certificates
[
i
]);
cert_chain
[
cert_chain
.
length
]
=
cert
;
}
// extract public key at the tail of the chain
var
pk
=
ca
.
verifyChain
(
cert_chain
);
},
"
verifies
"
:
function
(
result
)
{
assert
.
isTrue
(
result
);
}
...
...
This diff is collapsed.
Click to expand it.
jwcrypto
@
54af6b4c
Compare
43535b13
...
54af6b4c
Subproject commit
43535b130439a8f346e5758ded8c8fc30e927162
Subproject commit
54af6b4cac37e8a4b6a90808bda07765f47125f5
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