Skip to content

Commit

Permalink
Bug 1350254 part 8. Switch CryptoKey to [Serializable]. r=baku
Browse files Browse the repository at this point in the history
The spec doesn't say to do this, but I think we should.  See
w3c/webcrypto#222

Differential Revision: https://phabricator.services.mozilla.com/D35722

UltraBlame original commit: e02c73e7bd4bed108e60527f81fb8af00e361bb6
  • Loading branch information
marco-c committed Oct 4, 2019
1 parent 4132df3 commit 0c77ca3
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 141 deletions.
134 changes: 1 addition & 133 deletions dom/base/StructuredCloneHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ mozilla
/
dom
/
CryptoKey
.
h
"
#
include
"
mozilla
/
dom
/
StructuredCloneBlob
.
h
Expand Down Expand Up @@ -248,17 +237,6 @@ mozilla
/
dom
/
SubtleCryptoBinding
.
h
"
#
include
"
mozilla
/
dom
/
ToJSValue
.
h
Expand Down Expand Up @@ -292,17 +270,6 @@ mozilla
/
dom
/
WebCryptoCommon
.
h
"
#
include
"
mozilla
/
dom
/
WebIDLSerializable
.
h
Expand Down Expand Up @@ -785,7 +752,7 @@ SCTAG_DOM_DOMPOINTREADONLY
0xffff8009
&
&
SCTAG_DOM_WEBCRYPTO_KEY
SCTAG_DOM_CRYPTOKEY
=
=
0xffff800a
Expand Down Expand Up @@ -1896,12 +1863,6 @@ if
aTag
=
=
SCTAG_DOM_WEBCRYPTO_KEY
|
|
aTag
=
=
SCTAG_DOM_URLSEARCHPARAMS
)
{
Expand All @@ -1924,59 +1885,6 @@ if
aTag
=
=
SCTAG_DOM_WEBCRYPTO_KEY
)
{
RefPtr
<
CryptoKey
>
key
=
new
CryptoKey
(
global
)
;
if
(
!
key
-
>
ReadStructuredClone
(
aReader
)
)
{
result
=
nullptr
;
}
else
{
result
=
key
-
>
WrapObject
(
aCx
nullptr
)
;
}
}
else
if
(
aTag
=
=
SCTAG_DOM_URLSEARCHPARAMS
)
{
Expand Down Expand Up @@ -2434,46 +2342,6 @@ aWriter
;
}
}
{
CryptoKey
*
key
=
nullptr
;
if
(
NS_SUCCEEDED
(
UNWRAP_OBJECT
(
CryptoKey
&
obj
key
)
)
)
{
return
JS_WriteUint32Pair
(
aWriter
SCTAG_DOM_WEBCRYPTO_KEY
0
)
&
&
key
-
>
WriteStructuredClone
(
aWriter
)
;
}
}
#
ifdef
MOZ_WEBRTC
Expand Down
2 changes: 1 addition & 1 deletion dom/base/StructuredCloneTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SCTAG_DOM_WASM
SCTAG_DOM_IMAGEDATA
SCTAG_DOM_DOMPOINT
SCTAG_DOM_DOMPOINTREADONLY
SCTAG_DOM_WEBCRYPTO_KEY
SCTAG_DOM_CRYPTOKEY
SCTAG_DOM_NULL_PRINCIPAL
SCTAG_DOM_SYSTEM_PRINCIPAL
SCTAG_DOM_CONTENT_PRINCIPAL
Expand Down
73 changes: 67 additions & 6 deletions dom/crypto/CryptoKey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5950,6 +5950,9 @@ CryptoKey
:
WriteStructuredClone
(
JSContext
*
aCX
JSStructuredCloneWriter
*
aWriter
Expand Down Expand Up @@ -6056,12 +6059,21 @@ aWriter
)
;
}
bool
already_AddRefed
<
CryptoKey
>
CryptoKey
:
:
ReadStructuredClone
(
JSContext
*
aCx
nsIGlobalObject
*
aGlobal
JSStructuredCloneReader
*
aReader
Expand All @@ -6076,9 +6088,21 @@ EnsureNSSInitializedChromeOrContent
)
{
return
false
nullptr
;
}
RefPtr
<
CryptoKey
>
key
=
new
CryptoKey
(
aGlobal
)
;
uint32_t
version
;
Expand All @@ -6094,6 +6118,9 @@ JS_ReadUint32Pair
(
aReader
&
key
-
>
mAttributes
&
version
Expand Down Expand Up @@ -6129,6 +6156,9 @@ pub
)
&
&
key
-
>
mAlgorithm
.
ReadStructuredClone
Expand All @@ -6143,7 +6173,7 @@ read
)
{
return
false
nullptr
;
}
if
Expand All @@ -6158,6 +6188,9 @@ Length
&
&
!
key
-
>
mSymKey
.
Assign
Expand All @@ -6167,7 +6200,7 @@ sym
)
{
return
false
nullptr
;
}
if
Expand All @@ -6181,6 +6214,9 @@ Length
0
)
{
key
-
>
mPrivateKey
=
CryptoKey
Expand All @@ -6203,6 +6239,9 @@ Length
0
)
{
key
-
>
mPublicKey
=
CryptoKey
Expand All @@ -6219,6 +6258,9 @@ if
!
(
(
key
-
>
GetKeyType
(
)
Expand All @@ -6227,6 +6269,9 @@ GetKeyType
SECRET
&
&
key
-
>
mSymKey
.
Length
Expand All @@ -6238,6 +6283,9 @@ Length
|
|
(
key
-
>
GetKeyType
(
)
Expand All @@ -6246,11 +6294,17 @@ GetKeyType
PRIVATE
&
&
key
-
>
mPrivateKey
)
|
|
(
key
-
>
GetKeyType
(
)
Expand All @@ -6259,17 +6313,24 @@ GetKeyType
PUBLIC
&
&
key
-
>
mPublicKey
)
)
)
{
return
false
nullptr
;
}
return
true
key
.
forget
(
)
;
}
}
Expand Down
Loading

0 comments on commit 0c77ca3

Please sign in to comment.