@@ -87,15 +87,6 @@ describe("JWE Crypto", () => {
8787 } ) ;
8888 } ) ;
8989
90- it ( "without publicKeyFingerprintType" , ( ) => {
91- const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
92- delete config [ "publicKeyFingerprintType" ] ;
93- assert . throws (
94- ( ) => new Crypto ( config ) ,
95- / C o n f i g n o t v a l i d : p r o p e r t i e s F i n g e r p r i n t s h o u l d b e : ' c e r t i f i c a t e ' o r ' p u b l i c K e y ' /
96- ) ;
97- } ) ;
98-
9990 it ( "without publicKeyFingerprintType, but providing the publicKeyFingerprint" , ( ) => {
10091 const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
10192 delete config [ "publicKeyFingerprintType" ] ;
@@ -108,16 +99,34 @@ describe("JWE Crypto", () => {
10899 config . publicKeyFingerprintType = "foobar" ;
109100 assert . throws (
110101 ( ) => new Crypto ( config ) ,
111- / C o n f i g n o t v a l i d : p r o p e r t i e s F i n g e r p r i n t s h o u l d b e : ' c e r t i f i c a t e ' o r ' p u b l i c K e y ' /
102+ / C o n f i g n o t v a l i d : p u b l i c K e y F i n g e r p r i n t T y p e s h o u l d b e : ' c e r t i f i c a t e ' o r ' p u b l i c K e y ' /
112103 ) ;
113104 } ) ;
114105
115- it ( "with right publicKeyFingerprintType: certificate" , ( ) => {
106+ it ( "with right publicKeyFingerprintType: certificate and dataEncoding: base64 " , ( ) => {
116107 const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
117108 config . publicKeyFingerprintType = "certificate" ;
109+ config . dataEncoding = "base64" ;
118110 assert . doesNotThrow ( ( ) => new Crypto ( config ) ) ;
119111 } ) ;
120112
113+ it ( "with right publicKeyFingerprintType: certificate and dataEncoding: hex" , ( ) => {
114+ const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
115+ config . publicKeyFingerprintType = "certificate" ;
116+ config . dataEncoding = "hex" ;
117+ assert . doesNotThrow ( ( ) => new Crypto ( config ) ) ;
118+ } ) ;
119+
120+ it ( "with right publicKeyFingerprintType: certificate and dataEncoding: null" , ( ) => {
121+ const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
122+ config . publicKeyFingerprintType = "certificate" ;
123+ delete config [ "dataEncoding" ] ;
124+ assert . throws (
125+ ( ) => new Crypto ( config ) ,
126+ / C o n f i g n o t v a l i d : i f p u b l i c K e y F i n g e r p r i n t T y p e i s ' c e r t i f i c a t e ' d a t a E n c o d i n g m u s t b e e i t h e r ' b a s e 6 4 ' o r ' h e x ' /
127+ ) ;
128+ } ) ;
129+
121130 it ( "with right publicKeyFingerprintType: publicKey" , ( ) => {
122131 const config = JSON . parse ( JSON . stringify ( testConfig ) ) ;
123132 config . publicKeyFingerprintType = "publicKey" ;
@@ -249,5 +258,18 @@ describe("JWE Crypto", () => {
249258 } )
250259 ) ;
251260 } ) ;
261+
262+ it ( "compute public fingerprint: defaults to publicKey with publicKeyFingerprintType set" , ( ) => {
263+ const strippedConfig = JSON . parse ( JSON . stringify ( testConfig ) ) ;
264+ delete strippedConfig [ "publicKeyFingerprintType" ] ;
265+ delete strippedConfig [ "dataEncoding" ] ;
266+
267+ assert . ok (
268+ "80810fc13a8319fcf0e2ec322c82a4c304b782cc3ce671176343cfe8160c2279" ,
269+ computePublicFingerprint . call ( crypto , {
270+ strippedConfig
271+ } )
272+ ) ;
273+ } ) ;
252274 } ) ;
253275} ) ;
0 commit comments