File tree Expand file tree Collapse file tree 2 files changed +58
-1
lines changed
src/Renci.SshNet/Security Expand file tree Collapse file tree 2 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 1+ #if NET
2+ using System . Security . Cryptography ;
3+
4+ namespace Renci . SshNet . Security
5+ {
6+ internal abstract partial class KeyExchangeECCurve25519
7+ {
8+ protected sealed class BclImpl : Impl
9+ {
10+ private readonly ECCurve _curve ;
11+ private readonly ECDiffieHellman _clientECDH ;
12+
13+ public BclImpl ( ECCurve curve )
14+ {
15+ _curve = curve ;
16+ _clientECDH = ECDiffieHellman . Create ( ) ;
17+ }
18+
19+ public override byte [ ] GenerateClientECPoint ( )
20+ {
21+ _clientECDH . GenerateKey ( _curve ) ;
22+
23+ var q = _clientECDH . PublicKey . ExportParameters ( ) . Q ;
24+
25+ return q . X ;
26+ }
27+
28+ public override byte [ ] CalculateAgreement ( byte [ ] serverECPoint )
29+ {
30+ var parameters = new ECParameters
31+ {
32+ Curve = _curve ,
33+ Q = new ECPoint
34+ {
35+ X = serverECPoint ,
36+ Y = new byte [ serverECPoint . Length ]
37+ } ,
38+ } ;
39+
40+ using var serverECDH = ECDiffieHellman . Create ( parameters ) ;
41+
42+ return _clientECDH . DeriveRawSecretAgreement ( serverECDH . PublicKey ) ;
43+ }
44+
45+ protected override void Dispose ( bool disposing )
46+ {
47+ base . Dispose ( disposing ) ;
48+
49+ if ( disposing )
50+ {
51+ _clientECDH . Dispose ( ) ;
52+ }
53+ }
54+ }
55+ }
56+ }
57+ #endif
Original file line number Diff line number Diff line change 44
55namespace Renci . SshNet . Security
66{
7- internal abstract partial class KeyExchangeEC
7+ internal abstract partial class KeyExchangeECDH
88 {
99 protected sealed class BclImpl : Impl
1010 {
You can’t perform that action at this time.
0 commit comments