@@ -5,26 +5,39 @@ import { SSHAgentClient } from '../src/lib/ssh_agent_client.ts'
55
66chai . use ( chaiAsPromised )
77
8- describe ( 'RSA key mandatory tests' , ( ) => {
9- it ( "doesn't give the same signature twice with an ECDSA key" , async ( ) => {
8+ describe ( 'SSH key type tests' , ( ) => {
9+ it ( 'does give the same signature twice with RSA key' , async ( ) => {
1010 const agent = new SSHAgentClient ( )
11- const identity = await agent . getIdentity ( 'key_ecdsa ' )
11+ const identity = await agent . getIdentity ( 'key_rsa ' )
1212 if ( ! identity ) {
1313 throw new Error ( )
1414 }
15- const signature1 = await agent . sign ( identity , Buffer . from ( 'hello' , 'utf8' ) )
16- const signature2 = await agent . sign ( identity , Buffer . from ( 'hello' , 'utf8' ) )
17- chai . assert . notEqual ( signature1 , signature2 )
15+ const buffer = Buffer . from ( 'not_a_secret' , 'utf8' )
16+ const signature1 = await agent . sign ( identity , buffer )
17+ const signature2 = await agent . sign ( identity , buffer )
18+ chai . assert . equal ( signature1 . signature , signature2 . signature )
1819 } )
19- it ( "doesn't give the same signature twice with an ED25519 key" , async ( ) => {
20+ it ( 'does give the same signature twice with ED25519 key' , async ( ) => {
2021 const agent = new SSHAgentClient ( )
2122 const identity = await agent . getIdentity ( 'key_ed25519' )
2223 if ( ! identity ) {
2324 throw new Error ( )
2425 }
25- const signature1 = await agent . sign ( identity , Buffer . from ( 'hello' , 'utf8' ) )
26- const signature2 = await agent . sign ( identity , Buffer . from ( 'hello' , 'utf8' ) )
27- chai . assert . notEqual ( signature1 , signature2 )
26+ const buffer = Buffer . from ( 'not_a_secret' , 'utf8' )
27+ const signature1 = await agent . sign ( identity , buffer )
28+ const signature2 = await agent . sign ( identity , buffer )
29+ chai . assert . equal ( signature1 . signature , signature2 . signature )
30+ } )
31+ it ( "doesn't give the same signature twice with an ECDSA key" , async ( ) => {
32+ const agent = new SSHAgentClient ( )
33+ const identity = await agent . getIdentity ( 'key_ecdsa' )
34+ if ( ! identity ) {
35+ throw new Error ( )
36+ }
37+ const buffer = Buffer . from ( 'not_a_secret' , 'utf8' )
38+ const signature1 = await agent . sign ( identity , buffer )
39+ const signature2 = await agent . sign ( identity , buffer )
40+ chai . assert . notEqual ( signature1 . signature , signature2 . signature )
2841 } )
2942 it ( 'should throw if using ECDSA key for encrypting' , async ( ) => {
3043 const agent = new SSHAgentClient ( )
@@ -52,24 +65,4 @@ describe('RSA key mandatory tests', () => {
5265 'ecdsa-sha2-nistp256 key is forbidden, it always gives different signatures!' ,
5366 )
5467 } )
55- it ( 'should throw if using ED25519 key for encrypting' , async ( ) => {
56- const agent = new SSHAgentClient ( )
57- const identity = await agent . getIdentity ( 'key_ed25519' )
58- if ( ! identity ) {
59- throw new Error ( )
60- }
61- return chai
62- . expect ( agent . encrypt ( identity , 'not_a_secret' , Buffer . from ( '' , 'utf8' ) ) )
63- . to . be . rejectedWith ( Error , 'ssh-ed25519 key is forbidden, it always gives different signatures!' )
64- } )
65- it ( 'should throw if using ED25519 key for decrypting' , async ( ) => {
66- const agent = new SSHAgentClient ( )
67- const identity = await agent . getIdentity ( 'key_ed25519' )
68- if ( ! identity ) {
69- throw new Error ( )
70- }
71- return chai
72- . expect ( agent . decrypt ( identity , 'not_a_secret' , '' ) )
73- . to . be . rejectedWith ( Error , 'ssh-ed25519 key is forbidden, it always gives different signatures!' )
74- } )
7568} )
0 commit comments