mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-05 12:50:30 +09:00
Compare commits
938 Commits
libssh-0.9
...
libssh-0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10e09e273f | ||
|
|
622421018b | ||
|
|
8977e246b6 | ||
|
|
8b66d037d5 | ||
|
|
63ff242131 | ||
|
|
610d7a09f9 | ||
|
|
89df759200 | ||
|
|
5846e57538 | ||
|
|
0870c8db28 | ||
|
|
4cef5e965a | ||
|
|
2c492ee179 | ||
|
|
cea841d71c | ||
|
|
62d3101c1f | ||
|
|
d7467498fd | ||
|
|
22492b69bb | ||
|
|
9bbb817c0c | ||
|
|
c618040967 | ||
|
|
8615c24647 | ||
|
|
a66b4a6eae | ||
|
|
c2c56bacab | ||
|
|
52ebecf81c | ||
|
|
4b935d0785 | ||
|
|
57b92b18d6 | ||
|
|
48f217176f | ||
|
|
e8474e1ba3 | ||
|
|
85ce922bc4 | ||
|
|
49ead8f08e | ||
|
|
0813b75799 | ||
|
|
29ad26db26 | ||
|
|
cd2bf21f9a | ||
|
|
ed8b7ea7a7 | ||
|
|
105835d542 | ||
|
|
479eca13aa | ||
|
|
994acfe2c5 | ||
|
|
968e09aae0 | ||
|
|
a006d34372 | ||
|
|
a669408201 | ||
|
|
c68a58575b | ||
|
|
e8dfbb85a2 | ||
|
|
dc1254d53e | ||
|
|
d08f1b2377 | ||
|
|
70565ac438 | ||
|
|
fc1a8bb455 | ||
|
|
b759ae557d | ||
|
|
6df2daea04 | ||
|
|
99760776d4 | ||
|
|
247a4a761c | ||
|
|
a30339d7b1 | ||
|
|
8dde4e1924 | ||
|
|
b1d9bff6ee | ||
|
|
a0f10b9860 | ||
|
|
7e40f13125 | ||
|
|
36273e708a | ||
|
|
41c63fa88d | ||
|
|
d726eca7d2 | ||
|
|
ad2797613e | ||
|
|
653e5ee117 | ||
|
|
d8b1b5e0cc | ||
|
|
7341615e2f | ||
|
|
f8ba2b0148 | ||
|
|
d26cc63dd5 | ||
|
|
e41dacbf10 | ||
|
|
e786bacb92 | ||
|
|
19e2521242 | ||
|
|
429d0422dc | ||
|
|
559ebc9ccb | ||
|
|
d7f18c468e | ||
|
|
f73dac8eed | ||
|
|
3c381565c9 | ||
|
|
833c3d3330 | ||
|
|
6d073f2746 | ||
|
|
fe83733a7c | ||
|
|
d3d7eeab75 | ||
|
|
8a037e9afe | ||
|
|
dd0aaec67e | ||
|
|
8b3b041096 | ||
|
|
e9e9190079 | ||
|
|
bc4afc1067 | ||
|
|
6a187990c1 | ||
|
|
ec5bd83e50 | ||
|
|
e818700734 | ||
|
|
9e20e180e6 | ||
|
|
e426664623 | ||
|
|
921efbeea1 | ||
|
|
03f8fcae84 | ||
|
|
ea639b0258 | ||
|
|
bb5bdac321 | ||
|
|
554fe06aeb | ||
|
|
298155da71 | ||
|
|
44ceeb4d53 | ||
|
|
0c725d7602 | ||
|
|
2461027f72 | ||
|
|
967082c207 | ||
|
|
1f7995ccea | ||
|
|
662fe00c15 | ||
|
|
0d86688da2 | ||
|
|
02f39b5e60 | ||
|
|
1bf87909e7 | ||
|
|
096416d306 | ||
|
|
019040f693 | ||
|
|
f1c5888553 | ||
|
|
8a5bdc3a21 | ||
|
|
3a77bb2992 | ||
|
|
b2ca8b07ec | ||
|
|
1bc9b20b1a | ||
|
|
b9a6fac062 | ||
|
|
2eee844025 | ||
|
|
be2084f9e2 | ||
|
|
cfa95d9ead | ||
|
|
1685c14024 | ||
|
|
7f12c572d3 | ||
|
|
2177c9e567 | ||
|
|
96bc6af2b3 | ||
|
|
ec33973319 | ||
|
|
512ac7620b | ||
|
|
d190053660 | ||
|
|
253658dce8 | ||
|
|
8ac8b19017 | ||
|
|
e8838f419b | ||
|
|
2b45e61f74 | ||
|
|
54bcce5aa2 | ||
|
|
1fb95070f2 | ||
|
|
438cc6df52 | ||
|
|
4aeb685b04 | ||
|
|
54a3da64ad | ||
|
|
e21ceae755 | ||
|
|
905049d1e1 | ||
|
|
2c03f3bd0b | ||
|
|
e218745d0e | ||
|
|
24c44e2c7a | ||
|
|
7fd953ef42 | ||
|
|
80c994ef72 | ||
|
|
5c5811bf7c | ||
|
|
27f3e955e8 | ||
|
|
54a0eb6846 | ||
|
|
8c17a79797 | ||
|
|
13363975d8 | ||
|
|
e8dccfe1dd | ||
|
|
bff436695b | ||
|
|
e3d0f60281 | ||
|
|
92eedd8f19 | ||
|
|
a29f98be26 | ||
|
|
53bc265987 | ||
|
|
d993088553 | ||
|
|
5d26b0967d | ||
|
|
0d52be0f5b | ||
|
|
fc66be08a1 | ||
|
|
13a2aa3a97 | ||
|
|
4a36e52bc4 | ||
|
|
01a92b5838 | ||
|
|
e5f72468b8 | ||
|
|
1761db6f97 | ||
|
|
73ea9a8922 | ||
|
|
78e79fbc35 | ||
|
|
990db53ee6 | ||
|
|
18b46a6e17 | ||
|
|
096996501b | ||
|
|
569164740d | ||
|
|
0da3fe245b | ||
|
|
b448c3ad98 | ||
|
|
02e0eaa104 | ||
|
|
82e76a15d1 | ||
|
|
bddbe2a76d | ||
|
|
e8322817a9 | ||
|
|
e0c2f2809b | ||
|
|
9bb91df20f | ||
|
|
783f2b97a8 | ||
|
|
8d05810255 | ||
|
|
1d29d4b627 | ||
|
|
787711a271 | ||
|
|
ddea657ba7 | ||
|
|
9ae46bc364 | ||
|
|
fd1563575f | ||
|
|
1f973320a8 | ||
|
|
4fc7ab4399 | ||
|
|
87bac425a0 | ||
|
|
0e637e3327 | ||
|
|
9b1f4e9bf6 | ||
|
|
630f335415 | ||
|
|
b7934ab370 | ||
|
|
0aaad9eb25 | ||
|
|
8fe4cabb26 | ||
|
|
1689b83d0f | ||
|
|
7c6105882b | ||
|
|
bb6d1b78dc | ||
|
|
5a884b8c5a | ||
|
|
90128929e7 | ||
|
|
a7d509ca50 | ||
|
|
d26f7253a9 | ||
|
|
3ad2a21d13 | ||
|
|
7f6b3fab4e | ||
|
|
cd7ccf93f0 | ||
|
|
5944124428 | ||
|
|
8c40b2491d | ||
|
|
3331b794bc | ||
|
|
02f1873b9e | ||
|
|
5da93db25a | ||
|
|
b18495b56b | ||
|
|
a96763b195 | ||
|
|
540257b421 | ||
|
|
b657eeb65e | ||
|
|
4a87515026 | ||
|
|
886ed379d8 | ||
|
|
9b9197d86b | ||
|
|
64e89affeb | ||
|
|
2c1ad3262a | ||
|
|
14ff31490f | ||
|
|
3db3511467 | ||
|
|
4c5da86f91 | ||
|
|
2564246024 | ||
|
|
146d1a620d | ||
|
|
19c43ff6b7 | ||
|
|
58a2943d42 | ||
|
|
54c5472b53 | ||
|
|
17e9cd70a5 | ||
|
|
cee5c9f404 | ||
|
|
43fb1d7c8d | ||
|
|
5c629f22f6 | ||
|
|
46e0703c6e | ||
|
|
cffa103378 | ||
|
|
ea6558b3a6 | ||
|
|
33e12317c3 | ||
|
|
d17c635617 | ||
|
|
dde5fd8d38 | ||
|
|
46e78aaa3a | ||
|
|
3107133d10 | ||
|
|
b9ccaf6e23 | ||
|
|
38b17e6e6e | ||
|
|
db0a1d6811 | ||
|
|
ced93a09d1 | ||
|
|
3cff0eaa25 | ||
|
|
51c7816bea | ||
|
|
11a7c7b45b | ||
|
|
78d109596c | ||
|
|
b80ad81d8e | ||
|
|
20c13a2c76 | ||
|
|
a9dddd89aa | ||
|
|
7792d38157 | ||
|
|
fdf518435c | ||
|
|
debd0ea4d3 | ||
|
|
51c940adc9 | ||
|
|
d30cf11cb6 | ||
|
|
e5bc5ffd04 | ||
|
|
4b92d48085 | ||
|
|
a2a037a821 | ||
|
|
4719c09e6a | ||
|
|
4f09bb3660 | ||
|
|
594608f21b | ||
|
|
c437ba5c28 | ||
|
|
3efe7c3cfb | ||
|
|
b44b749f28 | ||
|
|
9837471c2e | ||
|
|
d92e389a80 | ||
|
|
0dce42c8fd | ||
|
|
face3aadb4 | ||
|
|
738cedb8be | ||
|
|
b6a4330fe4 | ||
|
|
2abd4bfb6c | ||
|
|
0c08159f53 | ||
|
|
9caedca2c6 | ||
|
|
e0985fc0b4 | ||
|
|
4978f30320 | ||
|
|
332f1c2e09 | ||
|
|
63e09908f1 | ||
|
|
b34f8e6efa | ||
|
|
ab07668d54 | ||
|
|
f6ad8057a7 | ||
|
|
51a53cc6d4 | ||
|
|
899ec9e519 | ||
|
|
7bcc2d83a4 | ||
|
|
2ba4b51e0f | ||
|
|
1be117b351 | ||
|
|
bdeb7418c5 | ||
|
|
f18cc433db | ||
|
|
65256ad5f6 | ||
|
|
86057e60f2 | ||
|
|
a889527c1b | ||
|
|
ca51565056 | ||
|
|
4b20d7ad18 | ||
|
|
442599f0d1 | ||
|
|
eb9dc8cfc4 | ||
|
|
07f4d5e723 | ||
|
|
c9263dea2b | ||
|
|
e0bceea815 | ||
|
|
7bd850ab36 | ||
|
|
4b3a6342db | ||
|
|
2aa137947a | ||
|
|
daabd78742 | ||
|
|
1d238694e7 | ||
|
|
6623856e08 | ||
|
|
9e03bf9f1e | ||
|
|
b312d4681e | ||
|
|
254bfd6d73 | ||
|
|
2420e4a981 | ||
|
|
b4d532b809 | ||
|
|
79ad989cf4 | ||
|
|
100017982d | ||
|
|
dd318aa1a1 | ||
|
|
fef0b3208a | ||
|
|
ddd0367e9c | ||
|
|
41b4d50e52 | ||
|
|
b408f5724a | ||
|
|
1c0372e0aa | ||
|
|
8b9b45066b | ||
|
|
97a03083ba | ||
|
|
88bc364c05 | ||
|
|
41e2d17119 | ||
|
|
3084b2bc41 | ||
|
|
af9018ce13 | ||
|
|
196fe36971 | ||
|
|
b5ce8fa96a | ||
|
|
70d3760daa | ||
|
|
2edb4b50ac | ||
|
|
f97ff7c2e8 | ||
|
|
4975487c18 | ||
|
|
ded3a17738 | ||
|
|
0b14e40710 | ||
|
|
24ac4a0129 | ||
|
|
ea83a27371 | ||
|
|
d171a6e444 | ||
|
|
44665f33a4 | ||
|
|
2e68cfbf40 | ||
|
|
bf7149f205 | ||
|
|
354438e758 | ||
|
|
314c57d414 | ||
|
|
2756eae1c7 | ||
|
|
afcb85bfda | ||
|
|
86ee3f5a00 | ||
|
|
14991ad071 | ||
|
|
6f634af4fb | ||
|
|
a52c66008e | ||
|
|
c573adced4 | ||
|
|
42d1efe4f9 | ||
|
|
0aa3b4ee81 | ||
|
|
e5e3c6267c | ||
|
|
ba8ce64a1d | ||
|
|
d76d5c633f | ||
|
|
227f416183 | ||
|
|
99c6eb305e | ||
|
|
21b6418fd9 | ||
|
|
ce26b56e13 | ||
|
|
f2f680aede | ||
|
|
1a831cfe2c | ||
|
|
95539ba0eb | ||
|
|
4a2758ecd6 | ||
|
|
1ab2340644 | ||
|
|
76b7e0e9b5 | ||
|
|
f8817c0c35 | ||
|
|
f5211239f9 | ||
|
|
a3b2229a4e | ||
|
|
fd9fda67f9 | ||
|
|
a7d2fe9503 | ||
|
|
188d0785e1 | ||
|
|
63f97a3d03 | ||
|
|
6daa95f9c1 | ||
|
|
d1abe26be3 | ||
|
|
0bee5d5e97 | ||
|
|
7dfed5c3cb | ||
|
|
925dc92d52 | ||
|
|
9eba361ca2 | ||
|
|
f2bd44969b | ||
|
|
dbe504ea0a | ||
|
|
14276f0b51 | ||
|
|
672c1f8a3a | ||
|
|
592d256a0b | ||
|
|
aac975b7b2 | ||
|
|
c40576c6f6 | ||
|
|
6aa88e22d6 | ||
|
|
bd7bef8b50 | ||
|
|
fb8d120bec | ||
|
|
286a706394 | ||
|
|
b6b5c59223 | ||
|
|
f7369423a4 | ||
|
|
a8a74a70fa | ||
|
|
3b29e2ad4c | ||
|
|
3ab17e3fbd | ||
|
|
c027585a50 | ||
|
|
ef02e524df | ||
|
|
50934a542d | ||
|
|
07245c1cdd | ||
|
|
094aeeafbe | ||
|
|
cfd883196d | ||
|
|
d2182bb7af | ||
|
|
ae44d846b8 | ||
|
|
dfcf793a9f | ||
|
|
7657994aed | ||
|
|
7ab6194a82 | ||
|
|
d2a41e606b | ||
|
|
9b7c4307a4 | ||
|
|
c9e6461546 | ||
|
|
5c919c4edb | ||
|
|
9bff4cb9b9 | ||
|
|
43a31b81f2 | ||
|
|
46624648f9 | ||
|
|
e909bde2c5 | ||
|
|
605f7fb2de | ||
|
|
ba04f788f4 | ||
|
|
30b548af02 | ||
|
|
9e0d76fb67 | ||
|
|
8ea7fc6129 | ||
|
|
aef467ab4a | ||
|
|
053ed5bd91 | ||
|
|
b59184fc89 | ||
|
|
d5099dec54 | ||
|
|
5904f19592 | ||
|
|
1a24b424ef | ||
|
|
25f9ca83a4 | ||
|
|
51b7a2421a | ||
|
|
78036e98ec | ||
|
|
c10d06b322 | ||
|
|
a5bb333422 | ||
|
|
c8b2e68fb8 | ||
|
|
0679945383 | ||
|
|
b90cc79cbe | ||
|
|
cb7ce1813b | ||
|
|
a9061ab434 | ||
|
|
ae809b3cbb | ||
|
|
8e56585c72 | ||
|
|
d4258d1461 | ||
|
|
c50cfe7fc7 | ||
|
|
486ad81974 | ||
|
|
c3ae1336fb | ||
|
|
95a4651d86 | ||
|
|
832abe7f4a | ||
|
|
cdac4fca5f | ||
|
|
a4b8045fb8 | ||
|
|
44dfee778f | ||
|
|
710815674a | ||
|
|
816f06e172 | ||
|
|
38806e1dd8 | ||
|
|
a1e8c985d1 | ||
|
|
da36ecd6f2 | ||
|
|
385ac0911d | ||
|
|
1991bdac0d | ||
|
|
8eb15e5cff | ||
|
|
8852fd3ac9 | ||
|
|
41c08986ae | ||
|
|
b6bf5bfd15 | ||
|
|
d1806a523c | ||
|
|
ba88e0fba5 | ||
|
|
6f934cc488 | ||
|
|
d005163ace | ||
|
|
7e99867533 | ||
|
|
e20fe54f3f | ||
|
|
919387ae64 | ||
|
|
0987e6065c | ||
|
|
daeee74edd | ||
|
|
f6a2f6190c | ||
|
|
3c33c39455 | ||
|
|
a0e19239b8 | ||
|
|
b36a5988be | ||
|
|
abc88c025c | ||
|
|
026879e9f0 | ||
|
|
4708fc3b10 | ||
|
|
9c6404aa49 | ||
|
|
455a161ed7 | ||
|
|
51f220fd41 | ||
|
|
b25feb3386 | ||
|
|
635edc8adb | ||
|
|
42741b1883 | ||
|
|
39cbe8178e | ||
|
|
22f89e043b | ||
|
|
f9bd1db8c3 | ||
|
|
5348267fa8 | ||
|
|
ccb5d6e0ac | ||
|
|
693383d1ef | ||
|
|
a6f4f9b43a | ||
|
|
03d7f7e9eb | ||
|
|
400f4f2329 | ||
|
|
b3a11e0185 | ||
|
|
cbd48c497f | ||
|
|
cc953ff7e4 | ||
|
|
d10f971bbb | ||
|
|
e4c5f6d3d9 | ||
|
|
b052f665c9 | ||
|
|
ff599a9c53 | ||
|
|
be419dee0d | ||
|
|
88d4fa5352 | ||
|
|
c0b65ccc5a | ||
|
|
7aad964cef | ||
|
|
3e23fb8a24 | ||
|
|
90e56df74e | ||
|
|
906cc7e7e9 | ||
|
|
f85464b900 | ||
|
|
dcae43fa6b | ||
|
|
f10d80047c | ||
|
|
750e4f3f9d | ||
|
|
b0518552f1 | ||
|
|
1694606e12 | ||
|
|
a76badf77a | ||
|
|
245ad744b5 | ||
|
|
10b3ebbe61 | ||
|
|
2782cb0495 | ||
|
|
533d881b0f | ||
|
|
866e4442b5 | ||
|
|
39bb93a53b | ||
|
|
4e4711d2fb | ||
|
|
7eb6c7ee6c | ||
|
|
d3f7b64579 | ||
|
|
7de9722d23 | ||
|
|
641a80be74 | ||
|
|
bee8ed82ab | ||
|
|
4149cebd64 | ||
|
|
425c02cb94 | ||
|
|
ad8dedd4a4 | ||
|
|
e26e98e59f | ||
|
|
ae184db913 | ||
|
|
b88aa98550 | ||
|
|
08a70bb474 | ||
|
|
3d0ecd37fe | ||
|
|
2e7ca3e8a6 | ||
|
|
b90131dfe6 | ||
|
|
4f976ce5c4 | ||
|
|
239eef6322 | ||
|
|
201fd66176 | ||
|
|
e6aee24a1e | ||
|
|
46499b1b90 | ||
|
|
62a0229f16 | ||
|
|
5411e0821f | ||
|
|
44de453b22 | ||
|
|
7c20875891 | ||
|
|
0c7a772301 | ||
|
|
c45cfce166 | ||
|
|
e76332bbd6 | ||
|
|
99e0ad75a6 | ||
|
|
154765ae8c | ||
|
|
6417f5a3ca | ||
|
|
fe0fcbbc67 | ||
|
|
c2f64108a1 | ||
|
|
59ac79c4dc | ||
|
|
7f57717f84 | ||
|
|
db948bdac8 | ||
|
|
6941958b49 | ||
|
|
1ba6ef689f | ||
|
|
fecdc3cc0e | ||
|
|
04ae110c61 | ||
|
|
9ac2d14707 | ||
|
|
bab2c775da | ||
|
|
945829a5dd | ||
|
|
58d53f1397 | ||
|
|
eebb02fff5 | ||
|
|
54296787a7 | ||
|
|
70478619ce | ||
|
|
a881c318ac | ||
|
|
5f1d0c4795 | ||
|
|
1ff6dda616 | ||
|
|
e3e3a27863 | ||
|
|
0f33eecc01 | ||
|
|
dba2114ed7 | ||
|
|
e3e52394c1 | ||
|
|
b36272eac1 | ||
|
|
cd15043656 | ||
|
|
9eb1ce88ae | ||
|
|
d2f0d3270a | ||
|
|
a9a7c2dc29 | ||
|
|
8e00d1f0a8 | ||
|
|
fc694a5c49 | ||
|
|
c79e67ca1e | ||
|
|
9914809ae3 | ||
|
|
45d82b3e36 | ||
|
|
7f869e4c99 | ||
|
|
b2c7fce968 | ||
|
|
960d952380 | ||
|
|
3845f77d76 | ||
|
|
b06b936819 | ||
|
|
3feb6ebe28 | ||
|
|
a64737cef6 | ||
|
|
f529659f76 | ||
|
|
3aea2ad53f | ||
|
|
6bd2b93f43 | ||
|
|
46c54e5ddb | ||
|
|
bbfce454de | ||
|
|
3e5dc99198 | ||
|
|
c8222dc1f6 | ||
|
|
c5fa08a2a4 | ||
|
|
89194e0d3a | ||
|
|
35224092eb | ||
|
|
a9e39a41ff | ||
|
|
0ece6e52aa | ||
|
|
f208e4b332 | ||
|
|
9fcb559301 | ||
|
|
875b2a5b59 | ||
|
|
702e7e4c85 | ||
|
|
8542f675f4 | ||
|
|
faedadf2eb | ||
|
|
73f383a2e6 | ||
|
|
862b2341d7 | ||
|
|
17b518a677 | ||
|
|
3664ba2800 | ||
|
|
30d03498b4 | ||
|
|
022409e99c | ||
|
|
07f571f1c0 | ||
|
|
ac1c31bda1 | ||
|
|
60a987fd17 | ||
|
|
94fe7634e1 | ||
|
|
8670fb101b | ||
|
|
e31e7b0406 | ||
|
|
6644f8ca3b | ||
|
|
06d25497ff | ||
|
|
8215753402 | ||
|
|
10d27a0d42 | ||
|
|
240bf3236a | ||
|
|
844f92efea | ||
|
|
dd8b6b1708 | ||
|
|
72498bac5f | ||
|
|
4b4f568a68 | ||
|
|
6324014866 | ||
|
|
12d5c136f2 | ||
|
|
7f5e14698f | ||
|
|
1fe5f03fff | ||
|
|
df1f64d435 | ||
|
|
94846b1d15 | ||
|
|
4d493c4da5 | ||
|
|
ee2fa29798 | ||
|
|
6d3941e71b | ||
|
|
e5553a92d9 | ||
|
|
3a6751f3d2 | ||
|
|
dd64980662 | ||
|
|
24f450fed1 | ||
|
|
9d5616a18c | ||
|
|
c106cd1f83 | ||
|
|
7e692ee1b6 | ||
|
|
dd54ffb2f1 | ||
|
|
3642224ee5 | ||
|
|
9b858f57c5 | ||
|
|
13c88a2e0a | ||
|
|
059b6851dc | ||
|
|
71ba61cc5b | ||
|
|
30cc1568f4 | ||
|
|
8eda4165cf | ||
|
|
1563bddf88 | ||
|
|
e2841908fb | ||
|
|
2892b49a37 | ||
|
|
4b85934198 | ||
|
|
9e7de14d59 | ||
|
|
bba5fa18ed | ||
|
|
1089948346 | ||
|
|
7ec67011c5 | ||
|
|
177e76f753 | ||
|
|
3d2570ff5f | ||
|
|
3063a57fc8 | ||
|
|
23c529c888 | ||
|
|
2b76abb74c | ||
|
|
fa95fe3e1b | ||
|
|
cc1175a9af | ||
|
|
4ea09256f6 | ||
|
|
6bf4ada240 | ||
|
|
86a0dfa65b | ||
|
|
89ec52f5b1 | ||
|
|
bbc72ed3b6 | ||
|
|
843052dd23 | ||
|
|
317cf070e2 | ||
|
|
2a22211e7f | ||
|
|
105e6f05ba | ||
|
|
ac22e51e5a | ||
|
|
fa6fb83c87 | ||
|
|
314448786e | ||
|
|
35216e7254 | ||
|
|
5317ebf0fc | ||
|
|
08f4469e21 | ||
|
|
de4b8f88a2 | ||
|
|
af5de2d37e | ||
|
|
b94ecf18bd | ||
|
|
d2a32ca6d3 | ||
|
|
e42307bbe3 | ||
|
|
742d81ec5d | ||
|
|
b03818aaed | ||
|
|
8c3996ef38 | ||
|
|
ecc78ec154 | ||
|
|
574690ae2e | ||
|
|
c7cacf986f | ||
|
|
31f9c39479 | ||
|
|
cf0beff987 | ||
|
|
178b53f924 | ||
|
|
e065d2bb3f | ||
|
|
9d67ca251c | ||
|
|
cb0ccf372e | ||
|
|
1fa1a467ed | ||
|
|
606a97c4d6 | ||
|
|
cc9db5b56c | ||
|
|
bab7ba0146 | ||
|
|
c9ce8fa40b | ||
|
|
6c79ed9801 | ||
|
|
7ae47df16a | ||
|
|
6734516278 | ||
|
|
3cf665a53d | ||
|
|
35799bb1c6 | ||
|
|
476bde4d69 | ||
|
|
0938d397be | ||
|
|
4e809ef122 | ||
|
|
80d092037f | ||
|
|
45d9802e1b | ||
|
|
5db5e7e527 | ||
|
|
d7abfe7e8f | ||
|
|
f422fb02f6 | ||
|
|
b719f705c6 | ||
|
|
3b8fcbad24 | ||
|
|
3ab8b76921 | ||
|
|
7c3a6ca6bc | ||
|
|
6eb34cec33 | ||
|
|
45ee892327 | ||
|
|
321b27b788 | ||
|
|
ac33b3adbc | ||
|
|
5e21c24fab | ||
|
|
abe1bf910e | ||
|
|
752c906ea7 | ||
|
|
1832ed4fef | ||
|
|
4cae57c581 | ||
|
|
9384a18e91 | ||
|
|
88a3dd86f1 | ||
|
|
449c0d66cc | ||
|
|
4cd084f13b | ||
|
|
9020f4e63a | ||
|
|
6596ee9fb2 | ||
|
|
25f1c80950 | ||
|
|
5e6cb6891f | ||
|
|
0684f1b94a | ||
|
|
42547772df | ||
|
|
288bbd5bd0 | ||
|
|
8525b4bb01 | ||
|
|
d97770b025 | ||
|
|
f89cf79c49 | ||
|
|
189fd76589 | ||
|
|
2786a3e96a | ||
|
|
09dfda8489 | ||
|
|
9a112f1548 | ||
|
|
4e2d85745f | ||
|
|
032f25aab3 | ||
|
|
da81b99df1 | ||
|
|
af2aeba838 | ||
|
|
9ae81c5ceb | ||
|
|
8aa2bbd0dc | ||
|
|
fff4120cbf | ||
|
|
7b9cbcebe5 | ||
|
|
56d571ab81 | ||
|
|
69daa602b8 | ||
|
|
924dc5aed8 | ||
|
|
6b8ab4bcd2 | ||
|
|
af2ea417da | ||
|
|
c7172c183f | ||
|
|
33cca875c2 | ||
|
|
b55d7f3b73 | ||
|
|
7588979977 | ||
|
|
ab26db203e | ||
|
|
d60640cd0e | ||
|
|
64155b4f97 | ||
|
|
64cd7e7ce2 | ||
|
|
f5bc5147b9 | ||
|
|
b5160ce9e0 | ||
|
|
fdb7cb8f17 | ||
|
|
fe9991b3c6 | ||
|
|
159d95c26c | ||
|
|
5ef416fd35 | ||
|
|
1be68139bb | ||
|
|
c820d2a2dc | ||
|
|
b18acbdc7e | ||
|
|
d672b1d7c4 | ||
|
|
d40f33c400 | ||
|
|
c29840060b | ||
|
|
98824d6e11 | ||
|
|
839fab6df4 | ||
|
|
6b105624bf | ||
|
|
db4345fb36 | ||
|
|
6cef3e10bf | ||
|
|
442d22da60 | ||
|
|
3cca9994d4 | ||
|
|
53635dff7e | ||
|
|
b7c628ff06 | ||
|
|
7823df8343 | ||
|
|
be34ff967f | ||
|
|
815f874964 | ||
|
|
f2d40fb94c | ||
|
|
31b26934b0 | ||
|
|
922a2aee99 | ||
|
|
500481e101 | ||
|
|
dad2720355 | ||
|
|
6f39deefcd | ||
|
|
0abd187dba | ||
|
|
07a57b74ba | ||
|
|
8d671efdbd | ||
|
|
3bad060738 | ||
|
|
fbe115abba | ||
|
|
66c4857c4a | ||
|
|
1434b4a279 | ||
|
|
8d62257172 | ||
|
|
0773696ee5 | ||
|
|
3830c7ae6e | ||
|
|
0b5ee39726 | ||
|
|
b82d2caa90 | ||
|
|
c4ad1aba98 | ||
|
|
c75d417d06 | ||
|
|
42c727d0c1 | ||
|
|
27bcac6845 | ||
|
|
e00ef9635a | ||
|
|
e60fc79542 | ||
|
|
c8a621c606 | ||
|
|
ec67ad47eb | ||
|
|
553eab748a | ||
|
|
2f1f662d46 | ||
|
|
7e3995d2dd | ||
|
|
77bd8ed4c0 | ||
|
|
39f6ba2dc9 | ||
|
|
3f64fb3b3b | ||
|
|
c54fd03e50 | ||
|
|
db632015be | ||
|
|
1ebf506913 | ||
|
|
fbc2912dde | ||
|
|
ea4f71721f | ||
|
|
4ab0fb2b48 | ||
|
|
8c36a865f2 | ||
|
|
82c57c1f36 | ||
|
|
c2c3545391 | ||
|
|
729c92606c | ||
|
|
498b63949e | ||
|
|
39f7ddaa06 | ||
|
|
2fcc15c5dc | ||
|
|
5e2788d4c5 | ||
|
|
29d360dc70 | ||
|
|
21655e396c | ||
|
|
b30875c6c7 | ||
|
|
d02c06268e | ||
|
|
e5767bf0b7 | ||
|
|
4a113159b2 | ||
|
|
a4b95268ee | ||
|
|
8a50dbc6ba | ||
|
|
85239c8ea0 | ||
|
|
040aa0edfe | ||
|
|
f97a8b4e3f | ||
|
|
d4fe8e1f62 | ||
|
|
e9e8292370 | ||
|
|
5a0177def0 | ||
|
|
17952c4953 | ||
|
|
fe18ef2798 | ||
|
|
689f1b0a6b | ||
|
|
a22367fbe1 | ||
|
|
46c3563da9 | ||
|
|
c983c994a2 | ||
|
|
c7da113f1d | ||
|
|
349abe5942 | ||
|
|
a3a0529b41 | ||
|
|
61e6b6cc59 | ||
|
|
d463f67aba | ||
|
|
0b7f7d2cf7 | ||
|
|
55cd04fbee | ||
|
|
2a2c1c98bf | ||
|
|
bdcaf55b90 | ||
|
|
a0b84a8cd5 | ||
|
|
97adbfe087 | ||
|
|
38ede2e225 | ||
|
|
90944a3651 | ||
|
|
7452f0ded8 | ||
|
|
7ffa3c358d | ||
|
|
e72429f205 | ||
|
|
aff7c500d5 | ||
|
|
aac682f60e | ||
|
|
2f05243a4a | ||
|
|
89a9eb8811 | ||
|
|
3cf2b41f5e | ||
|
|
223cc96239 | ||
|
|
61b1e0e7e9 | ||
|
|
6500134259 | ||
|
|
9b8b312b88 | ||
|
|
4900ab6ca9 | ||
|
|
618b858e49 | ||
|
|
83fa060cec | ||
|
|
4799915a36 | ||
|
|
92d3efec81 | ||
|
|
4e25ee6124 | ||
|
|
89ab7b23f8 | ||
|
|
3a61cd34a9 | ||
|
|
5b18bcb0ac | ||
|
|
742918cb1c | ||
|
|
7857cd1aa5 | ||
|
|
3737e5f0e7 | ||
|
|
e42d44e48a | ||
|
|
683096ae7e | ||
|
|
3811c73f8f | ||
|
|
cc92e74309 | ||
|
|
68baebbd62 | ||
|
|
33927f3ae8 | ||
|
|
c03c9b88d1 | ||
|
|
88d777e678 | ||
|
|
0a85f3a58d | ||
|
|
a5cad4e700 | ||
|
|
8ce6a889aa | ||
|
|
6e4e6f8da6 | ||
|
|
0734bc490f | ||
|
|
b275045ac8 | ||
|
|
85951a156b | ||
|
|
b5a8547d91 | ||
|
|
1a26c57af2 | ||
|
|
595c2c4336 | ||
|
|
343c90ccf4 | ||
|
|
7cd66d49f8 | ||
|
|
b2c7e0dd69 | ||
|
|
915c006a30 | ||
|
|
2884f97bc5 | ||
|
|
0d4658740b | ||
|
|
fed31c1ca3 | ||
|
|
68533147e2 | ||
|
|
24af712931 | ||
|
|
519074f13e | ||
|
|
946ac0ee28 | ||
|
|
5a50fc6b0d | ||
|
|
22f038189c | ||
|
|
f18a7cc17e | ||
|
|
65a38759ca | ||
|
|
548753b338 | ||
|
|
e5a64a3d6b | ||
|
|
ad68de7271 | ||
|
|
fe248414fe | ||
|
|
8e42ed8220 | ||
|
|
5617eaf0e2 | ||
|
|
4adb13d9e3 | ||
|
|
da50b12051 | ||
|
|
a82993b320 | ||
|
|
6a9185636f | ||
|
|
a1ee22eb64 | ||
|
|
1d54a3880d | ||
|
|
b1ff11f416 | ||
|
|
25bb6eef96 | ||
|
|
d00ff451db | ||
|
|
4b7ce75e1f | ||
|
|
c8f49becfd | ||
|
|
f64814b7be | ||
|
|
abf5712160 | ||
|
|
1aef599ab1 | ||
|
|
3d7d3f303e | ||
|
|
220f1e1435 | ||
|
|
17a531d2af | ||
|
|
a80547bdf9 | ||
|
|
a4fa514549 | ||
|
|
d5095a55b9 | ||
|
|
d627cba476 | ||
|
|
23c837f4d0 | ||
|
|
bd69ac63ca | ||
|
|
6c49c41c19 | ||
|
|
bd65568749 |
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
max_line_length = 80
|
||||||
|
end_of_line = lf
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.{c,h}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
|
||||||
|
[{CMakeLists.txt,*.cmake}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@
|
|||||||
*~$
|
*~$
|
||||||
cscope.*
|
cscope.*
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
/.cache
|
||||||
/.clangd
|
/.clangd
|
||||||
tags
|
tags
|
||||||
/build
|
/build
|
||||||
|
|||||||
890
.gitlab-ci.yml
890
.gitlab-ci.yml
@@ -1,509 +1,559 @@
|
|||||||
|
---
|
||||||
variables:
|
variables:
|
||||||
BUILD_IMAGES_PROJECT: libssh/build-images
|
BUILD_IMAGES_PROJECT: libssh/build-images
|
||||||
FEDORA_BUILD: buildenv-fedora
|
|
||||||
CENTOS7_BUILD: buildenv-centos7
|
CENTOS7_BUILD: buildenv-centos7
|
||||||
TUMBLEWEED_BUILD: buildenv-tumbleweed
|
CENTOS8_BUILD: buildenv-c8s
|
||||||
|
CENTOS9_BUILD: buildenv-c9s
|
||||||
|
FEDORA_BUILD: buildenv-fedora
|
||||||
MINGW_BUILD: buildenv-mingw
|
MINGW_BUILD: buildenv-mingw
|
||||||
|
TUMBLEWEED_BUILD: buildenv-tumbleweed
|
||||||
|
UBUNTU_BUILD: buildenv-ubuntu
|
||||||
|
ALPINE_BUILD: buildenv-alpine
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- review
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
- analysis
|
||||||
|
|
||||||
|
.build:
|
||||||
|
stage: build
|
||||||
|
variables:
|
||||||
|
CMAKE_DEFAULT_OPTIONS: "-DCMAKE_BUILD_TYPE=RelWithDebInfo -DPICKY_DEVELOPER=ON"
|
||||||
|
CMAKE_BUILD_OPTIONS: "-DWITH_BLOWFISH_CIPHER=ON -DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON -DWITH_DEBUG_CRYPTO=ON -DWITH_DEBUG_PACKET=ON -DWITH_DEBUG_CALLTRACE=ON -DWITH_DSA=ON"
|
||||||
|
CMAKE_TEST_OPTIONS: "-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DWITH_BENCHMARKS=ON"
|
||||||
|
CMAKE_OPTIONS: $CMAKE_DEFAULT_OPTIONS $CMAKE_BUILD_OPTIONS $CMAKE_TEST_OPTIONS
|
||||||
|
before_script: &build
|
||||||
|
- uname -a
|
||||||
|
- cat /etc/os-release
|
||||||
|
- mount
|
||||||
|
- df -h
|
||||||
|
- cat /proc/swaps
|
||||||
|
- free -h
|
||||||
|
- mkdir -p obj && cd obj
|
||||||
|
script:
|
||||||
|
- cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. &&
|
||||||
|
make -j$(nproc) &&
|
||||||
|
make -j$(nproc) install
|
||||||
|
# Do not use after_script as it does not make the targets fail
|
||||||
|
tags:
|
||||||
|
- shared
|
||||||
|
except:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
when: on_failure
|
||||||
|
paths:
|
||||||
|
- obj/
|
||||||
|
|
||||||
|
.tests:
|
||||||
|
extends: .build
|
||||||
|
stage: test
|
||||||
|
# This is needed to prevent passing artifacts from previous stages
|
||||||
|
dependencies: []
|
||||||
|
script:
|
||||||
|
- cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. &&
|
||||||
|
make -j$(nproc) &&
|
||||||
|
ctest --output-on-failure
|
||||||
|
# Do not use after_script as it does not make the targets fail
|
||||||
|
|
||||||
|
.fedora:
|
||||||
|
extends: .tests
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
||||||
|
variables:
|
||||||
|
CMAKE_ADDITIONAL_OPTIONS: -DWITH_PKCS11_URI=ON
|
||||||
|
|
||||||
|
.tumbleweed:
|
||||||
|
extends: .tests
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
||||||
|
|
||||||
|
.fips:
|
||||||
|
extends: .tests
|
||||||
|
variables:
|
||||||
|
# DSA is turned off in fips mode
|
||||||
|
CMAKE_ADDITIONAL_OPTIONS: -DWITH_PKCS11_URI=ON -DWITH_DSA=OFF
|
||||||
|
before_script:
|
||||||
|
- *build
|
||||||
|
- echo "# userspace fips" > /etc/system-fips
|
||||||
|
# We do not need the kernel part, but in case we ever do:
|
||||||
|
# mkdir -p /var/tmp/userspace-fips
|
||||||
|
# echo 1 > /var/tmp/userspace-fips/fips_enabled
|
||||||
|
# mount --bind /var/tmp/userspace-fips/fips_enabled \
|
||||||
|
# /proc/sys/crypto/fips_enabled
|
||||||
|
- update-crypto-policies --show
|
||||||
|
- update-crypto-policies --set FIPS
|
||||||
|
- update-crypto-policies --show
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# CentOS builds #
|
||||||
|
###############################################################################
|
||||||
# pkd tests fail on CentOS7 docker images, so we don't use -DSERVER_TESTING=ON
|
# pkd tests fail on CentOS7 docker images, so we don't use -DSERVER_TESTING=ON
|
||||||
centos7/openssl_1.0.x/x86_64:
|
centos7/openssl_1.0.x/x86_64:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD
|
||||||
|
extends: .tests
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake3
|
- cmake3 $CMAKE_OPTIONS .. &&
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
make -j$(nproc) &&
|
||||||
-DPICKY_DEVELOPER=ON
|
ctest --output-on-failure
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
|
||||||
-DUNIT_TESTING=ON -DCLIENT_TESTING=ON .. &&
|
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
fedora/openssl_1.1.x/x86_64:
|
centos9s/openssl_3.0.x/x86_64:
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS9_BUILD
|
||||||
|
extends: .tests
|
||||||
|
variables:
|
||||||
|
CMAKE_ADDITIONAL_OPTIONS: -DWITH_PKCS11_URI=ON
|
||||||
|
script:
|
||||||
|
- export OPENSSL_ENABLE_SHA1_SIGNATURES=1
|
||||||
|
- cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. &&
|
||||||
|
make -j$(nproc) &&
|
||||||
|
ctest --output-on-failure
|
||||||
|
|
||||||
|
centos9s/openssl_3.0.x/x86_64/fips:
|
||||||
|
extends: .fips
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS9_BUILD
|
||||||
|
script:
|
||||||
|
- export OPENSSL_ENABLE_SHA1_SIGNATURES=1
|
||||||
|
- cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. &&
|
||||||
|
make -j$(nproc) &&
|
||||||
|
OPENSSL_FORCE_FIPS_MODE=1 ctest --output-on-failure
|
||||||
|
|
||||||
|
centos8s/openssl_1.1.1/x86_64:
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS8_BUILD
|
||||||
|
extends: .tests
|
||||||
|
variables:
|
||||||
|
CMAKE_ADDITIONAL_OPTIONS: -DWITH_PKCS11_URI=ON
|
||||||
|
script:
|
||||||
|
- cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. &&
|
||||||
|
make -j$(nproc) &&
|
||||||
|
ctest --output-on-failure
|
||||||
|
|
||||||
|
centos8s/openssl_1.1.1/x86_64/fips:
|
||||||
|
extends: .fips
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS8_BUILD
|
||||||
|
script:
|
||||||
|
- cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. &&
|
||||||
|
make -j$(nproc) &&
|
||||||
|
OPENSSL_FORCE_FIPS_MODE=1 ctest --output-on-failure
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Fedora builds #
|
||||||
|
###############################################################################
|
||||||
|
fedora/build:
|
||||||
|
extends: .build
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
||||||
|
|
||||||
|
fedora/docs:
|
||||||
|
extends: .build
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- cmake .. && make docs
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
|
||||||
-DPICKY_DEVELOPER=ON
|
|
||||||
-DWITH_BLOWFISH_CIPHER=ON
|
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
|
||||||
-DWITH_DEBUG_CRYPTO=ON
|
|
||||||
-DWITH_DEBUG_PACKET=ON -DWITH_DEBUG_CALLTRACE=ON
|
|
||||||
-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON .. &&
|
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
fedora/openssl_1.1.x/x86_64/fips:
|
fedora/ninja:
|
||||||
|
extends: .fedora
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
||||||
script:
|
script:
|
||||||
- echo 1 > /etc/system-fips
|
- cmake -G Ninja $CMAKE_OPTIONS ../ && ninja && CTEST_OUTPUT_ON_FAILURE=1 ninja test
|
||||||
- update-crypto-policies --set FIPS
|
|
||||||
- mkdir -p obj && cd obj && cmake
|
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
|
||||||
-DPICKY_DEVELOPER=ON
|
|
||||||
-DWITH_BLOWFISH_CIPHER=ON
|
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
|
||||||
-DWITH_DEBUG_CRYPTO=ON -DWITH_DEBUG_PACKET=ON -DWITH_DEBUG_CALLTRACE=ON
|
|
||||||
-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON .. &&
|
|
||||||
make -j$(nproc) && OPENSSL_FORCE_FIPS_MODE=1 ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
fedora/openssl_1.1.x/x86_64/minimal:
|
fedora/openssl_3.0.x/x86_64:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
extends: .fedora
|
||||||
|
|
||||||
|
fedora/openssl_3.0.x/x86_64/minimal:
|
||||||
|
extends: .fedora
|
||||||
|
variables:
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- cmake $CMAKE_DEFAULT_OPTIONS
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
-DWITH_SFTP=OFF
|
||||||
-DPICKY_DEVELOPER=ON
|
-DWITH_SERVER=OFF
|
||||||
-DWITH_SFTP=OFF -DWITH_SERVER=OFF -DWITH_ZLIB=OFF -DWITH_PCAP=OFF
|
-DWITH_ZLIB=OFF
|
||||||
-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DWITH_GEX=OFF .. &&
|
-DWITH_PCAP=OFF
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
-DWITH_DSA=OFF
|
||||||
tags:
|
-DUNIT_TESTING=ON
|
||||||
- shared
|
-DCLIENT_TESTING=ON
|
||||||
except:
|
-DWITH_GEX=OFF .. &&
|
||||||
- tags
|
make -j$(nproc)
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
# Address sanitizer doesn't mix well with LD_PRELOAD used in the testsuite
|
# Address sanitizer doesn't mix well with LD_PRELOAD used in the testsuite
|
||||||
# so, this is only enabled for unit tests right now.
|
# so, this is only enabled for unit tests right now.
|
||||||
# TODO: add -DCLIENT_TESTING=ON -DSERVER_TESTING=ON
|
# TODO: add -DCLIENT_TESTING=ON -DSERVER_TESTING=ON
|
||||||
fedora/address-sanitizer:
|
fedora/address-sanitizer:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
extends: .fedora
|
||||||
|
stage: analysis
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- cmake
|
||||||
-DCMAKE_BUILD_TYPE=AddressSanitizer
|
-DCMAKE_BUILD_TYPE=AddressSanitizer
|
||||||
-DPICKY_DEVELOPER=ON
|
-DCMAKE_C_COMPILER=clang
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
-DCMAKE_CXX_COMPILER=clang++
|
||||||
-DUNIT_TESTING=ON .. &&
|
-DPICKY_DEVELOPER=ON
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
$CMAKE_BUILD_OPTIONS
|
||||||
tags:
|
-DUNIT_TESTING=ON
|
||||||
- shared
|
-DFUZZ_TESTING=ON .. &&
|
||||||
except:
|
make -j$(nproc) &&
|
||||||
- tags
|
ctest --output-on-failure
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
# This is disabled as it report OpenSSL issues
|
# This is disabled as it report OpenSSL issues
|
||||||
# It also has ethe same issues with cwrap as AddressSanitizer
|
# It also has the same issues with cwrap as AddressSanitizer
|
||||||
.fedora/memory-sanitizer:
|
.fedora/memory-sanitizer:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
extends: .fedora
|
||||||
|
stage: analysis
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- cmake
|
||||||
-DCMAKE_BUILD_TYPE=MemorySanitizer
|
-DCMAKE_BUILD_TYPE=MemorySanitizer
|
||||||
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
-DCMAKE_C_COMPILER=clang
|
||||||
-DPICKY_DEVELOPER=ON
|
-DCMAKE_CXX_COMPILER=clang++
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
-DPICKY_DEVELOPER=ON
|
||||||
-DUNIT_TESTING=ON ..
|
$CMAKE_BUILD_OPTIONS
|
||||||
&& make -j$(nproc) && ctest --output-on-failure
|
-DUNIT_TESTING=ON
|
||||||
tags:
|
-DFUZZ_TESTING=ON .. &&
|
||||||
- shared
|
make -j$(nproc) &&
|
||||||
except:
|
ctest --output-on-failure
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
fedora/undefined-sanitizer:
|
fedora/undefined-sanitizer:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
extends: .fedora
|
||||||
|
stage: analysis
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- cmake
|
||||||
-DCMAKE_BUILD_TYPE=UndefinedSanitizer
|
-DCMAKE_BUILD_TYPE=UndefinedSanitizer
|
||||||
-DPICKY_DEVELOPER=ON
|
-DCMAKE_C_COMPILER=clang
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
-DCMAKE_CXX_COMPILER=clang++
|
||||||
-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON ..
|
-DPICKY_DEVELOPER=ON
|
||||||
&& make -j$(nproc) && ctest --output-on-failure
|
$CMAKE_BUILD_OPTIONS
|
||||||
tags:
|
-DUNIT_TESTING=ON
|
||||||
- shared
|
-DFUZZ_TESTING=ON .. &&
|
||||||
except:
|
make -j$(nproc) &&
|
||||||
- tags
|
ctest --output-on-failure
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
fedora/csbuild:
|
fedora/libgcrypt/x86_64:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
extends: .fedora
|
||||||
|
variables:
|
||||||
|
CMAKE_ADDITIONAL_OPTIONS: "-DWITH_GCRYPT=ON -DWITH_DEBUG_CRYPTO=ON"
|
||||||
|
|
||||||
|
fedora/mbedtls/x86_64:
|
||||||
|
extends: .fedora
|
||||||
|
variables:
|
||||||
|
CMAKE_ADDITIONAL_OPTIONS: "-DWITH_MBEDTLS=ON -DWITH_DEBUG_CRYPTO=ON -DWITH_DSA=OFF"
|
||||||
|
|
||||||
|
# Unit testing only, no client and pkd testing, because cwrap is not available
|
||||||
|
# for MinGW
|
||||||
|
fedora/mingw64:
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
|
||||||
|
extends: .tests
|
||||||
script:
|
script:
|
||||||
- |
|
- export WINEPATH=/usr/x86_64-w64-mingw32/sys-root/mingw/bin
|
||||||
if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
|
- export WINEDEBUG=-all
|
||||||
export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
|
- mingw64-cmake $CMAKE_DEFAULT_OPTIONS
|
||||||
fi
|
-DWITH_SFTP=ON
|
||||||
|
-DWITH_SERVER=ON
|
||||||
|
-DWITH_ZLIB=ON
|
||||||
|
-DWITH_PCAP=ON
|
||||||
|
-DUNIT_TESTING=ON .. &&
|
||||||
|
make -j$(nproc) &&
|
||||||
|
ctest --output-on-failure
|
||||||
|
|
||||||
# Check if the commit exists in this branch
|
# Unit testing only, no client and pkd testing, because cwrap is not available
|
||||||
# This is not the case for a force push
|
# for MinGW
|
||||||
git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null || export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
|
fedora/mingw32:
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
|
||||||
|
extends: .tests
|
||||||
|
script:
|
||||||
|
- export WINEPATH=/usr/i686-w64-mingw32/sys-root/mingw/bin
|
||||||
|
- export WINEDEBUG=-all
|
||||||
|
- mingw32-cmake $CMAKE_DEFAULT_OPTIONS
|
||||||
|
-DWITH_SFTP=ON
|
||||||
|
-DWITH_SERVER=ON
|
||||||
|
-DWITH_ZLIB=ON
|
||||||
|
-DWITH_PCAP=ON
|
||||||
|
-DUNIT_TESTING=ON .. &&
|
||||||
|
make -j$(nproc) &&
|
||||||
|
ctest --output-on-failure
|
||||||
|
|
||||||
export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
|
|
||||||
|
|
||||||
- csbuild
|
###############################################################################
|
||||||
--build-dir=obj-csbuild
|
# Fedora csbuild #
|
||||||
--build-cmd "rm -rf CMakeFiles CMakeCache.txt && cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DFUZZ_TESTING=ON @SRCDIR@ && make clean && make -j$(nproc)"
|
###############################################################################
|
||||||
--git-commit-range $CI_COMMIT_RANGE
|
.csbuild:
|
||||||
--color
|
stage: analysis
|
||||||
--print-current --print-fixed
|
variables:
|
||||||
|
GIT_DEPTH: "100"
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
||||||
|
before_script:
|
||||||
|
- |
|
||||||
|
if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
|
||||||
|
export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the commit exists in this branch
|
||||||
|
# This is not the case for a force push
|
||||||
|
git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null || export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
|
||||||
|
|
||||||
|
export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
|
||||||
tags:
|
tags:
|
||||||
- shared
|
- shared
|
||||||
except:
|
except:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
when: on_failure
|
when: on_failure
|
||||||
paths:
|
paths:
|
||||||
- obj-csbuild/
|
- obj-csbuild/
|
||||||
|
|
||||||
# That is a specific runner that we cannot enable universally.
|
fedora/csbuild/openssl_3.0.x:
|
||||||
# We restrict it to builds under the $BUILD_IMAGES_PROJECT project.
|
extends: .csbuild
|
||||||
freebsd/x86_64:
|
|
||||||
image:
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- csbuild
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
--build-dir=obj-csbuild
|
||||||
-DPICKY_DEVELOPER=ON
|
--build-cmd "rm -rf CMakeFiles CMakeCache.txt && cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DFUZZ_TESTING=ON -DWITH_DSA=ON @SRCDIR@ && make clean && make -j$(nproc)"
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
--git-commit-range $CI_COMMIT_RANGE
|
||||||
-DUNIT_TESTING=ON .. &&
|
--color
|
||||||
make && ctest --output-on-failure
|
--print-current --print-fixed
|
||||||
tags:
|
|
||||||
- freebsd
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
only:
|
|
||||||
- branches@libssh/libssh-mirror
|
|
||||||
- branches@cryptomilk/libssh-mirror
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
fedora/libgcrypt/x86_64:
|
fedora/csbuild/libgcrypt:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
extends: .csbuild
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- csbuild
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
--build-dir=obj-csbuild
|
||||||
-DPICKY_DEVELOPER=ON
|
--build-cmd "rm -rf CMakeFiles CMakeCache.txt && cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DFUZZ_TESTING=ON -DWITH_GCRYPT=ON -DWITH_DSA=ON @SRCDIR@ && make clean && make -j$(nproc)"
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
--git-commit-range $CI_COMMIT_RANGE
|
||||||
-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON
|
--color
|
||||||
-DWITH_GCRYPT=ON -DWITH_DEBUG_CRYPTO=ON .. &&
|
--print-current --print-fixed
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
fedora/mbedtls/x86_64:
|
fedora/csbuild/mbedtls:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
extends: .csbuild
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- csbuild
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
--build-dir=obj-csbuild
|
||||||
-DPICKY_DEVELOPER=ON
|
--build-cmd "rm -rf CMakeFiles CMakeCache.txt && cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DFUZZ_TESTING=ON -DWITH_MBEDTLS=ON @SRCDIR@ && make clean && make -j$(nproc)"
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
--git-commit-range $CI_COMMIT_RANGE
|
||||||
-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON
|
--color
|
||||||
-DWITH_MBEDTLS=ON -DWITH_DEBUG_CRYPTO=ON .. &&
|
--print-current --print-fixed
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
# Unit testing only, no client and pkd testing, because cwrap is not available
|
|
||||||
# for MinGW
|
|
||||||
fedora/mingw64:
|
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
|
|
||||||
script:
|
|
||||||
- export WINEPATH=/usr/x86_64-w64-mingw32/sys-root/mingw/bin
|
|
||||||
- export WINEDEBUG=-all
|
|
||||||
- mkdir -p obj && cd obj && mingw64-cmake
|
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
|
||||||
-DPICKY_DEVELOPER=ON
|
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
|
||||||
-DUNIT_TESTING=ON .. &&
|
|
||||||
make -j$(nproc) &&
|
|
||||||
ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
# Unit testing only, no client and pkd testing, because cwrap is not available
|
###############################################################################
|
||||||
# for MinGW
|
# Ubuntu builds #
|
||||||
fedora/mingw32:
|
###############################################################################
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
|
ubuntu/openssl_3.0.x/x86_64:
|
||||||
script:
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$UBUNTU_BUILD
|
||||||
- export WINEPATH=/usr/i686-w64-mingw32/sys-root/mingw/bin
|
extends: .tests
|
||||||
- export WINEDEBUG=-all
|
|
||||||
- mkdir -p obj && cd obj && mingw32-cmake
|
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
|
||||||
-DPICKY_DEVELOPER=ON
|
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
|
||||||
-DUNIT_TESTING=ON .. &&
|
|
||||||
make -j$(nproc) &&
|
|
||||||
ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
tumbleweed/openssl_1.1.x/x86_64/gcc:
|
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
|
||||||
script:
|
|
||||||
- mkdir -p obj && cd obj && cmake
|
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
|
||||||
-DPICKY_DEVELOPER=ON
|
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
|
||||||
-DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config
|
|
||||||
-DUNIT_TESTING=ON -DSERVER_TESTING=ON .. &&
|
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
tumbleweed/openssl_1.1.x/x86/gcc:
|
###############################################################################
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
# Alpine builds #
|
||||||
|
###############################################################################
|
||||||
|
alpine/openssl_3.0.x/musl:
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$ALPINE_BUILD
|
||||||
|
extends: .tests
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- cmake $CMAKE_DEFAULT_OPTIONS
|
||||||
-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-m32.cmake
|
-DWITH_SFTP=ON
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
-DWITH_SERVER=ON
|
||||||
-DPICKY_DEVELOPER=ON
|
-DWITH_ZLIB=ON
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
-DWITH_PCAP=ON
|
||||||
-DUNIT_TESTING=ON .. &&
|
-DUNIT_TESTING=ON .. &&
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
make -j$(nproc) &&
|
||||||
tags:
|
ctest --output-on-failure
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
tumbleweed/openssl_1.1.x/x86_64/gcc7:
|
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
|
||||||
script:
|
|
||||||
- mkdir -p obj && cd obj && cmake
|
|
||||||
-DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
|
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
|
||||||
-DPICKY_DEVELOPER=ON
|
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
|
||||||
-DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config
|
|
||||||
-DUNIT_TESTING=ON -DSERVER_TESTING=ON .. &&
|
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
tumbleweed/openssl_1.1.x/x86/gcc7:
|
###############################################################################
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
# Tumbleweed builds #
|
||||||
script:
|
###############################################################################
|
||||||
- mkdir -p obj && cd obj && cmake
|
tumbleweed/openssl_3.0.x/x86_64/gcc:
|
||||||
-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-m32.cmake
|
extends: .tumbleweed
|
||||||
-DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
|
variables:
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
CMAKE_ADDITIONAL_OPTIONS: "-DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config"
|
||||||
-DPICKY_DEVELOPER=ON
|
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
|
||||||
-DUNIT_TESTING=ON .. &&
|
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
tumbleweed/openssl_1.1.x/x86_64/clang:
|
tumbleweed/openssl_3.0.x/x86/gcc:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
extends: .tumbleweed
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- cmake
|
||||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-m32.cmake
|
||||||
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
$CMAKE_DEFAULT_OPTIONS
|
||||||
-DPICKY_DEVELOPER=ON
|
-DWITH_SFTP=ON
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
-DWITH_SERVER=ON
|
||||||
-DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config
|
-DWITH_ZLIB=ON
|
||||||
-DUNIT_TESTING=ON
|
-DWITH_PCAP=ON
|
||||||
-DSERVER_TESTING=ON .. &&
|
-DWITH_DSA=ON
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
-DUNIT_TESTING=ON .. &&
|
||||||
tags:
|
make -j$(nproc)
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
tumbleweed/docs:
|
tumbleweed/openssl_3.0.x/x86_64/gcc7:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
extends: .tumbleweed
|
||||||
script:
|
variables:
|
||||||
- mkdir -p obj && cd obj && cmake .. && make docs
|
CMAKE_ADDITIONAL_OPTIONS: "-DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 -DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config"
|
||||||
tags:
|
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
when: on_failure
|
|
||||||
paths:
|
|
||||||
- obj/
|
|
||||||
|
|
||||||
tumbleweed/undefined-sanitizer:
|
tumbleweed/openssl_3.0.x/x86/gcc7:
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
extends: .tumbleweed
|
||||||
script:
|
script:
|
||||||
- mkdir -p obj && cd obj && cmake
|
- cmake
|
||||||
-DCMAKE_BUILD_TYPE=UndefinedSanitizer
|
-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-m32.cmake
|
||||||
-DPICKY_DEVELOPER=ON
|
-DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
$CMAKE_DEFAULT_OPTIONS
|
||||||
-DUNIT_TESTING=ON -DSERVER_TESTING=ON .. &&
|
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
||||||
make -j$(nproc) && ctest --output-on-failure
|
-DWITH_DSA=ON
|
||||||
tags:
|
-DUNIT_TESTING=ON .. &&
|
||||||
- shared
|
make -j$(nproc) &&
|
||||||
except:
|
ctest --output-on-failure
|
||||||
- tags
|
|
||||||
artifacts:
|
tumbleweed/openssl_3.0.x/x86_64/clang:
|
||||||
expire_in: 1 week
|
extends: .tumbleweed
|
||||||
when: on_failure
|
variables:
|
||||||
paths:
|
CMAKE_ADDITIONAL_OPTIONS: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config"
|
||||||
- obj/
|
|
||||||
|
|
||||||
tumbleweed/static-analysis:
|
tumbleweed/static-analysis:
|
||||||
|
extends: .tests
|
||||||
|
stage: analysis
|
||||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
|
||||||
script:
|
script:
|
||||||
- export CCC_CC=clang
|
- export CCC_CC=clang
|
||||||
- export CCC_CXX=clang++
|
- export CCC_CXX=clang++
|
||||||
- mkdir -p obj && cd obj && scan-build cmake
|
- scan-build cmake
|
||||||
-DCMAKE_BUILD_TYPE=Debug
|
-DCMAKE_BUILD_TYPE=Debug
|
||||||
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
-DCMAKE_C_COMPILER=clang
|
||||||
-DPICKY_DEVELOPER=ON
|
-DCMAKE_CXX_COMPILER=clang++
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
-DPICKY_DEVELOPER=ON
|
||||||
-DUNIT_TESTING=ON -DSERVER_TESTING=ON .. &&
|
$CMAKE_BUILD_OPTIONS
|
||||||
scan-build --status-bugs -o scan make -j$(nproc)
|
$CMAKE_TEST_OPTIONS .. &&
|
||||||
tags:
|
scan-build --status-bugs -o scan make -j$(nproc)
|
||||||
- shared
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
when: on_failure
|
when: on_failure
|
||||||
paths:
|
paths:
|
||||||
- obj/scan
|
- obj/scan
|
||||||
|
|
||||||
visualstudio/x86_64:
|
|
||||||
script:
|
###############################################################################
|
||||||
- $env:VCPKG_DEFAULT_TRIPLET="x64-windows"
|
# FreeBSD builds #
|
||||||
- cd obj
|
###############################################################################
|
||||||
- cmake
|
# That is a specific runner that we cannot enable universally.
|
||||||
-A x64
|
# We restrict it to builds under the $BUILD_IMAGES_PROJECT project.
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_TOOLCHAIN_FILE"
|
freebsd/openssl_1.1.1/x86_64:
|
||||||
|
image:
|
||||||
|
extends: .tests
|
||||||
|
before_script:
|
||||||
|
- mkdir -p obj && cd obj && cmake
|
||||||
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
-DPICKY_DEVELOPER=ON
|
-DPICKY_DEVELOPER=ON
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
||||||
-DUNIT_TESTING=ON ..
|
-DUNIT_TESTING=ON ..
|
||||||
- cmake --build .
|
script:
|
||||||
- ctest --output-on-failure
|
- cmake $CMAKE_DEFAULT_OPTIONS
|
||||||
|
-DWITH_SFTP=ON
|
||||||
|
-DWITH_SERVER=ON
|
||||||
|
-DWITH_ZLIB=ON
|
||||||
|
-DWITH_PCAP=ON
|
||||||
|
-DUNIT_TESTING=ON .. &&
|
||||||
|
make &&
|
||||||
|
ctest --output-on-failure
|
||||||
tags:
|
tags:
|
||||||
- vs2017
|
- private
|
||||||
- windows
|
- freebsd
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
only:
|
only:
|
||||||
- branches@libssh/libssh-mirror
|
- branches@libssh/libssh-mirror
|
||||||
- branches@ansasaki/libssh-mirror
|
- branches@cryptomilk/libssh-mirror
|
||||||
- branches@cryptomilk/libssh-mirror
|
- branches@jjelen/libssh-mirror
|
||||||
- branches@jjelen/libssh-mirror
|
- branches@marco.fortina/libssh-mirror
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Visual Studio builds #
|
||||||
|
###############################################################################
|
||||||
|
.vs:
|
||||||
|
stage: test
|
||||||
|
cache:
|
||||||
|
key: vcpkg.${CI_JOB_NAME}
|
||||||
|
paths:
|
||||||
|
- .vcpkg
|
||||||
|
variables:
|
||||||
|
ErrorActionPreference: STOP
|
||||||
|
script:
|
||||||
|
- cmake --build .
|
||||||
|
- ctest --output-on-failure
|
||||||
|
tags:
|
||||||
|
- windows
|
||||||
|
- shared-windows
|
||||||
|
except:
|
||||||
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
when: on_failure
|
when: on_failure
|
||||||
paths:
|
paths:
|
||||||
- obj/
|
- obj/
|
||||||
|
before_script:
|
||||||
|
- If (!(test-path .vcpkg\archives)) { mkdir -p .vcpkg\archives }
|
||||||
|
- $env:VCPKG_DEFAULT_BINARY_CACHE="$PWD\.vcpkg\archives"
|
||||||
|
- echo $env:VCPKG_DEFAULT_BINARY_CACHE
|
||||||
|
- $env:VCPKG_DEFAULT_TRIPLET="$TRIPLET-windows"
|
||||||
|
- vcpkg install cmocka
|
||||||
|
- vcpkg install openssl
|
||||||
|
- vcpkg install zlib
|
||||||
|
- vcpkg integrate install
|
||||||
|
- mkdir -p obj; if ($?) {cd obj}; if (! $?) {exit 1}
|
||||||
|
- cmake
|
||||||
|
-A $PLATFORM
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||||
|
-DPICKY_DEVELOPER=ON
|
||||||
|
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
||||||
|
-DUNIT_TESTING=ON ..
|
||||||
|
|
||||||
|
visualstudio/x86_64:
|
||||||
|
extends: .vs
|
||||||
|
variables:
|
||||||
|
PLATFORM: "x64"
|
||||||
|
TRIPLET: "x64"
|
||||||
|
|
||||||
visualstudio/x86:
|
visualstudio/x86:
|
||||||
|
extends: .vs
|
||||||
|
variables:
|
||||||
|
PLATFORM: "win32"
|
||||||
|
TRIPLET: "x86"
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Coverity #
|
||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# git push -o ci.variable="COVERITY_SCAN_TOKEN=XXXXXX" \
|
||||||
|
# -o ci.variable="COVERITY_SCAN_PROJECT_NAME=XXXXXX" \
|
||||||
|
# -o ci.variable="COVERITY_SCAN_EMAIL=XXXXXX" \
|
||||||
|
# -f gitlab
|
||||||
|
|
||||||
|
coverity:
|
||||||
|
stage: analysis
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS9_BUILD
|
||||||
script:
|
script:
|
||||||
- $env:VCPKG_DEFAULT_TRIPLET="x86-windows"
|
- mkdir obj && cd obj
|
||||||
- cd obj
|
- wget https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_SCAN_TOKEN&project=$COVERITY_SCAN_PROJECT_NAME" -O /tmp/coverity_tool.tgz
|
||||||
- cmake
|
- tar xf /tmp/coverity_tool.tgz
|
||||||
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_TOOLCHAIN_FILE"
|
- cmake -DCMAKE_BUILD_TYPE=Debug $CMAKE_BUILD_OPTIONS $CMAKE_TEST_OPTIONS ..
|
||||||
-DPICKY_DEVELOPER=ON
|
- cov-analysis-linux64-*/bin/cov-build --dir cov-int make -j$(nproc)
|
||||||
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
|
- tar czf cov-int.tar.gz cov-int
|
||||||
-DUNIT_TESTING=ON ..
|
- curl
|
||||||
- cmake --build .
|
--form token=$COVERITY_SCAN_TOKEN
|
||||||
- ctest --output-on-failure
|
--form email=$COVERITY_SCAN_EMAIL
|
||||||
|
--form file=@cov-int.tar.gz
|
||||||
|
--form version="`git describe --tags`"
|
||||||
|
--form description="CI build"
|
||||||
|
https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
|
||||||
tags:
|
tags:
|
||||||
- vs2017
|
- shared
|
||||||
- windows
|
|
||||||
except:
|
|
||||||
- tags
|
|
||||||
only:
|
only:
|
||||||
- branches@libssh/libssh-mirror
|
refs:
|
||||||
- branches@ansasaki/libssh-mirror
|
- master
|
||||||
- branches@cryptomilk/libssh-mirror
|
- schedules
|
||||||
- branches@jjelen/libssh-mirror
|
variables:
|
||||||
|
- $COVERITY_SCAN_TOKEN != null
|
||||||
|
- $COVERITY_SCAN_PROJECT_NAME != null
|
||||||
|
- $COVERITY_SCAN_EMAIL != null
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
when: on_failure
|
when: on_failure
|
||||||
paths:
|
paths:
|
||||||
- obj/
|
- obj/cov-int/*.txt
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Codespell #
|
||||||
|
###############################################################################
|
||||||
|
codespell:
|
||||||
|
stage: review
|
||||||
|
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
||||||
|
script:
|
||||||
|
- codespell --ignore-words-list=keypair,sorce,ned,nd,ue
|
||||||
|
tags:
|
||||||
|
- shared
|
||||||
|
|||||||
@@ -1,5 +1,131 @@
|
|||||||
ChangeLog
|
CHANGELOG
|
||||||
==========
|
=========
|
||||||
|
version 0.10.6 (released 2023-12-18)
|
||||||
|
* Fix CVE-2023-6004: Command injection using proxycommand
|
||||||
|
* Fix CVE-2023-48795: Potential downgrade attack using strict kex
|
||||||
|
* Fix CVE-2023-6918: Missing checks for return values of MD functions
|
||||||
|
* Fix ssh_send_issue_banner() for CMD(PowerShell)
|
||||||
|
* Avoid passing other events to callbacks when poll is called recursively (#202)
|
||||||
|
* Allow @ in usernames when parsing from URI composes
|
||||||
|
|
||||||
|
version 0.10.5 (released 2023-05-04)
|
||||||
|
* Fix CVE-2023-1667: a NULL dereference during rekeying with algorithm guessing
|
||||||
|
* Fix CVE-2023-2283: a possible authorization bypass in
|
||||||
|
pki_verify_data_signature under low-memory conditions.
|
||||||
|
* Fix several memory leaks in GSSAPI handling code
|
||||||
|
* Escape braces in ProxyCommand created from ProxyJump options for zsh
|
||||||
|
compatibility.
|
||||||
|
* Fix pkg-config path relocation for MinGW
|
||||||
|
* Improve doxygen documentation
|
||||||
|
* Fix build with cygwin due to the glob support
|
||||||
|
* Do not enqueue outgoing packets after sending SSH2_MSG_NEWKEYS
|
||||||
|
* Add support for SSH_SUPPRESS_DEPRECATED
|
||||||
|
* Avoid functions declarations without prototype to build with clang 15
|
||||||
|
* Fix spelling issues
|
||||||
|
* Avoid expanding KnownHosts, ProxyCommands and IdentityFiles repetitively
|
||||||
|
* Add support sk-* keys through configuration
|
||||||
|
* Improve checking for Argp library
|
||||||
|
* Log information about received extensions
|
||||||
|
* Correctly handle rekey with delayed compression
|
||||||
|
* Move the EC keys handling to OpenSSL 3.0 API
|
||||||
|
* Record peer disconnect message
|
||||||
|
* Avoid deadlock when write buffering occurs and we call poll recursively to
|
||||||
|
flush the output buffer
|
||||||
|
* Disable preauthentication compression by default
|
||||||
|
* Add CentOS 8 Stream / OpenSSL 1.1.1 to CI
|
||||||
|
* Add accidentally removed default compile flags
|
||||||
|
* Solve incorrect parsing of ProxyCommand option
|
||||||
|
|
||||||
|
version 0.10.4 (released 2022-09-07)
|
||||||
|
* Fixed issues with KDF on big endian
|
||||||
|
|
||||||
|
version 0.10.3 (released 2022-09-05)
|
||||||
|
* Fixed possible infinite loop in known hosts checking
|
||||||
|
|
||||||
|
version 0.10.2 (released 2022-09-02)
|
||||||
|
* Fixed tilde expansion when handling include directives
|
||||||
|
* Fixed building the shared torture library
|
||||||
|
* Made rekey test more robust (fixes running on i586 build systems e.g koji)
|
||||||
|
|
||||||
|
version 0.10.1 (released 2022-08-30)
|
||||||
|
* Fixed proxycommand support
|
||||||
|
* Fixed musl libc support
|
||||||
|
|
||||||
|
version 0.10.0 (released 2022-08-26)
|
||||||
|
* Added support for OpenSSL 3.0
|
||||||
|
* Added support for mbedTLS 3
|
||||||
|
* Added support for Smart Cards (through openssl pkcs11 engine)
|
||||||
|
* Added support for chacha20-poly1305@openssh.com with libgcrypt
|
||||||
|
* Added support ed25519 keys in PEM files
|
||||||
|
* Added support for sk-ecdsa and sk-ed25519 (server side)
|
||||||
|
* Added support for limiting RSA key sizes and not accepting small one by
|
||||||
|
default
|
||||||
|
* Added support for ssh-agent on Windows
|
||||||
|
* Added ssh_userauth_publickey_auto_get_current_identity() API
|
||||||
|
* Added ssh_vlog() API
|
||||||
|
* Added ssh_send_issue_banner() API
|
||||||
|
* Added ssh_session_set_disconnect_message() API
|
||||||
|
* Added new configuration options:
|
||||||
|
+ IdentityAgent
|
||||||
|
+ ModuliFile
|
||||||
|
* Provided X11 client example
|
||||||
|
* Disabled DSA support at build time by default (will be removed in the next
|
||||||
|
release)
|
||||||
|
* Deprecated the SCP API!
|
||||||
|
* Deprecated old pubkey, privatekey API
|
||||||
|
* Avoided some needless large stack buffers to minimize memory footprint
|
||||||
|
* Removed support for OpenSSL < 1.0.1
|
||||||
|
* Fixed parsing username@host in login name
|
||||||
|
* Free global init mutex in the destructor on Windows
|
||||||
|
* Fixed PEM parsing in mbedtls to support both legacy and new PKCS8 formats
|
||||||
|
|
||||||
|
version 0.9.6 (released 2021-08-26)
|
||||||
|
* CVE-2021-3634: Fix possible heap-buffer overflow when rekeying with
|
||||||
|
different key exchange mechanism
|
||||||
|
* Fix several memory leaks on error paths
|
||||||
|
* Reset pending_call_state on disconnect
|
||||||
|
* Fix handshake bug with AEAD ciphers and no HMAC overlap
|
||||||
|
* Use OPENSSL_CRYPTO_LIBRARIES in CMake
|
||||||
|
* Ignore request success and failure message if they are not expected
|
||||||
|
* Support more identity files in configuration
|
||||||
|
* Avoid setting compiler flags directly in CMake
|
||||||
|
* Support build directories with special characters
|
||||||
|
* Include stdlib.h to avoid crash in Windows
|
||||||
|
* Fix sftp_new_channel constructs an invalid object
|
||||||
|
* Fix Ninja multiple rules error
|
||||||
|
* Several tests fixes
|
||||||
|
|
||||||
|
version 0.9.5 (released 2020-09-10)
|
||||||
|
* CVE-2020-16135: Avoid null pointer dereference in sftpserver (T232)
|
||||||
|
* Improve handling of library initialization (T222)
|
||||||
|
* Fix parsing of subsecond times in SFTP (T219)
|
||||||
|
* Make the documentation reproducible
|
||||||
|
* Remove deprecated API usage in OpenSSL
|
||||||
|
* Fix regression of ssh_channel_poll_timeout() returning SSH_AGAIN
|
||||||
|
* Define version in one place (T226)
|
||||||
|
* Prevent invalid free when using different C runtimes than OpenSSL (T229)
|
||||||
|
* Compatibility improvements to testsuite
|
||||||
|
|
||||||
|
version 0.9.4 (released 2020-04-09)
|
||||||
|
* Fixed CVE-2020-1730 - Possible DoS in client and server when handling
|
||||||
|
AES-CTR keys with OpenSSL
|
||||||
|
* Added diffie-hellman-group14-sha256
|
||||||
|
* Fixed several possible memory leaks
|
||||||
|
|
||||||
|
version 0.9.3 (released 2019-12-10)
|
||||||
|
* Fixed CVE-2019-14889 - SCP: Unsanitized location leads to command execution
|
||||||
|
* SSH-01-003 Client: Missing NULL check leads to crash in erroneous state
|
||||||
|
* SSH-01-006 General: Various unchecked Null-derefs cause DOS
|
||||||
|
* SSH-01-007 PKI Gcrypt: Potential UAF/double free with RSA pubkeys
|
||||||
|
* SSH-01-010 SSH: Deprecated hash function in fingerprinting
|
||||||
|
* SSH-01-013 Conf-Parsing: Recursive wildcards in hostnames lead to DOS
|
||||||
|
* SSH-01-014 Conf-Parsing: Integer underflow leads to OOB array access
|
||||||
|
* SSH-01-001 State Machine: Initial machine states should be set explicitly
|
||||||
|
* SSH-01-002 Kex: Differently bound macros used to iterate same array
|
||||||
|
* SSH-01-005 Code-Quality: Integer sign confusion during assignments
|
||||||
|
* SSH-01-008 SCP: Protocol Injection via unescaped File Names
|
||||||
|
* SSH-01-009 SSH: Update documentation which RFCs are implemented
|
||||||
|
* SSH-01-012 PKI: Information leak via uninitialized stack buffer
|
||||||
|
|
||||||
version 0.9.2 (released 2019-11-07)
|
version 0.9.2 (released 2019-11-07)
|
||||||
* Fixed libssh-config.cmake
|
* Fixed libssh-config.cmake
|
||||||
@@ -20,7 +146,7 @@ version 0.9.1 (released 2019-10-25)
|
|||||||
* Fixed deprecation issues (T165)
|
* Fixed deprecation issues (T165)
|
||||||
* Fixed known_hosts directory creation (T166)
|
* Fixed known_hosts directory creation (T166)
|
||||||
|
|
||||||
version 0.9.0 (released 2019-06-28)
|
version 0.9.0 (released 2019-02-xx)
|
||||||
* Added support for AES-GCM
|
* Added support for AES-GCM
|
||||||
* Added improved rekeying support
|
* Added improved rekeying support
|
||||||
* Added performance improvements
|
* Added performance improvements
|
||||||
@@ -35,71 +161,6 @@ version 0.9.0 (released 2019-06-28)
|
|||||||
* Improved documentation
|
* Improved documentation
|
||||||
* Improved OpenSSL API usage for KEX, DH, and signatures
|
* Improved OpenSSL API usage for KEX, DH, and signatures
|
||||||
|
|
||||||
version 0.8.7 (released 2019-02-25)
|
|
||||||
* Fixed handling extension flags in the server implementation
|
|
||||||
* Fixed exporting ed25519 private keys
|
|
||||||
* Fixed corner cases for rsa-sha2 signatures
|
|
||||||
* Fixed some issues with connector
|
|
||||||
|
|
||||||
version 0.8.6 (released 2018-12-24)
|
|
||||||
* Fixed compilation issues with different OpenSSL versions
|
|
||||||
* Fixed StrictHostKeyChecking in new knownhosts API
|
|
||||||
* Fixed ssh_send_keepalive() with packet filter
|
|
||||||
* Fixed possible crash with knownhosts options
|
|
||||||
* Fixed issus with rekeying
|
|
||||||
* Fixed strong ECDSA keys
|
|
||||||
* Fixed some issues with rsa-sha2 extentions
|
|
||||||
* Fixed access violation in ssh_init() (static linking)
|
|
||||||
* Fixed ssh_channel_close() handling
|
|
||||||
|
|
||||||
version 0.8.5 (released 2018-10-29)
|
|
||||||
* Added support to get known_hosts locations with ssh_options_get()
|
|
||||||
* Fixed preferred algorithm for known hosts negotiations
|
|
||||||
* Fixed KEX with some server implementations (e.g. Cisco)
|
|
||||||
* Fixed issues with MSVC
|
|
||||||
* Fixed keyboard-interactive auth in server mode
|
|
||||||
(regression from CVE-2018-10933)
|
|
||||||
* Fixed gssapi auth in server mode (regression from CVE-2018-10933)
|
|
||||||
* Fixed socket fd handling with proxy command
|
|
||||||
* Fixed a memory leak with OpenSSL
|
|
||||||
|
|
||||||
version 0.8.4 (released 2018-10-16)
|
|
||||||
* Fixed CVE-2018-10933
|
|
||||||
* Fixed building without globbing support
|
|
||||||
* Fixed possible memory leaks
|
|
||||||
* Avoid SIGPIPE on sockets
|
|
||||||
|
|
||||||
version 0.8.3 (released 2018-09-21)
|
|
||||||
* Added support for rsa-sha2
|
|
||||||
* Added support to parse private keys in openssh container format
|
|
||||||
(other than ed25519)
|
|
||||||
* Added support for diffie-hellman-group18-sha512 and
|
|
||||||
diffie-hellman-group16-sha512
|
|
||||||
* Added ssh_get_fingerprint_hash()
|
|
||||||
* Added ssh_pki_export_privkey_base64()
|
|
||||||
* Added support for Match keyword in config file
|
|
||||||
* Improved performance and reduced memory footprint for sftp
|
|
||||||
* Fixed ecdsa publickey auth
|
|
||||||
* Fixed reading a closed channel
|
|
||||||
* Added support to announce posix-rename@openssh.com and
|
|
||||||
hardlink@openssh.com in the sftp server
|
|
||||||
|
|
||||||
version 0.8.2 (released 2018-08-30)
|
|
||||||
* Added sha256 fingerprints for pubkeys
|
|
||||||
* Improved compiler flag detection
|
|
||||||
* Fixed race condition in reading sftp messages
|
|
||||||
* Fixed doxygen generation and added modern style
|
|
||||||
* Fixed library initialization on Windows
|
|
||||||
* Fixed __bounded__ attribute detection
|
|
||||||
* Fixed a bug in the options parser
|
|
||||||
* Fixed documentation for new knwon_hosts API
|
|
||||||
|
|
||||||
version 0.8.1 (released 2018-08-13)
|
|
||||||
* Fixed version number in the header
|
|
||||||
* Fixed version number in pkg-config and cmake config
|
|
||||||
* Fixed library initialization
|
|
||||||
* Fixed attribute detection
|
|
||||||
|
|
||||||
version 0.8.0 (released 2018-08-10)
|
version 0.8.0 (released 2018-08-10)
|
||||||
* Removed support for deprecated SSHv1 protocol
|
* Removed support for deprecated SSHv1 protocol
|
||||||
* Added new connector API for clients
|
* Added new connector API for clients
|
||||||
@@ -200,7 +261,7 @@ version 0.6.1 (released 2014-02-08)
|
|||||||
* Fixed DSA signature extraction.
|
* Fixed DSA signature extraction.
|
||||||
* Fixed some memory leaks.
|
* Fixed some memory leaks.
|
||||||
* Fixed read of non-connected socket.
|
* Fixed read of non-connected socket.
|
||||||
* Fixed thread dectection.
|
* Fixed thread detection.
|
||||||
|
|
||||||
version 0.6.0 (released 2014-01-08)
|
version 0.6.0 (released 2014-01-08)
|
||||||
* Added new publicy key API.
|
* Added new publicy key API.
|
||||||
@@ -225,7 +286,7 @@ version 0.6.0 (released 2014-01-08)
|
|||||||
version 0.5.5 (released 2013-07-26)
|
version 0.5.5 (released 2013-07-26)
|
||||||
* BUG 103: Fix ProxyCommand parsing.
|
* BUG 103: Fix ProxyCommand parsing.
|
||||||
* Fix setting -D_FORTIFY_SOURCE=2.
|
* Fix setting -D_FORTIFY_SOURCE=2.
|
||||||
* Fix pollset error return if emtpy.
|
* Fix pollset error return if empty.
|
||||||
* Fix NULL pointer checks in channel functions.
|
* Fix NULL pointer checks in channel functions.
|
||||||
* Several bugfixes.
|
* Several bugfixes.
|
||||||
|
|
||||||
@@ -241,7 +302,7 @@ version 0.5.3 (released 2012-11-20)
|
|||||||
* BUG #84 - Fix bug in sftp_mkdir not returning on error.
|
* BUG #84 - Fix bug in sftp_mkdir not returning on error.
|
||||||
* BUG #85 - Fixed a possible channel infinite loop if the connection dropped.
|
* BUG #85 - Fixed a possible channel infinite loop if the connection dropped.
|
||||||
* BUG #88 - Added missing channel request_state and set it to accepted.
|
* BUG #88 - Added missing channel request_state and set it to accepted.
|
||||||
* BUG #89 - Reset error state to no error on successful SSHv1 authentiction.
|
* BUG #89 - Reset error state to no error on successful SSHv1 authentication.
|
||||||
* Fixed a possible use after free in ssh_free().
|
* Fixed a possible use after free in ssh_free().
|
||||||
* Fixed multiple possible NULL pointer dereferences.
|
* Fixed multiple possible NULL pointer dereferences.
|
||||||
* Fixed multiple memory leaks in error paths.
|
* Fixed multiple memory leaks in error paths.
|
||||||
@@ -302,7 +363,7 @@ version 0.4.7 (released 2010-12-28)
|
|||||||
* Fixed a possible memory leak in ssh_get_user_home().
|
* Fixed a possible memory leak in ssh_get_user_home().
|
||||||
* Fixed a memory leak in sftp_xstat.
|
* Fixed a memory leak in sftp_xstat.
|
||||||
* Fixed uninitialized fd->revents member.
|
* Fixed uninitialized fd->revents member.
|
||||||
* Fixed timout value in ssh_channel_accept().
|
* Fixed timeout value in ssh_channel_accept().
|
||||||
* Fixed length checks in ssh_analyze_banner().
|
* Fixed length checks in ssh_analyze_banner().
|
||||||
* Fixed a possible data overread and crash bug.
|
* Fixed a possible data overread and crash bug.
|
||||||
* Fixed setting max_fd which breaks ssh_select().
|
* Fixed setting max_fd which breaks ssh_select().
|
||||||
@@ -325,7 +386,7 @@ version 0.4.5 (released 2010-07-13)
|
|||||||
* Added option to bind a client to an ip address.
|
* Added option to bind a client to an ip address.
|
||||||
* Fixed the ssh socket polling function.
|
* Fixed the ssh socket polling function.
|
||||||
* Fixed Windows related bugs in bsd_poll().
|
* Fixed Windows related bugs in bsd_poll().
|
||||||
* Fixed serveral build warnings.
|
* Fixed several build warnings.
|
||||||
|
|
||||||
version 0.4.4 (released 2010-06-01)
|
version 0.4.4 (released 2010-06-01)
|
||||||
* Fixed a bug in the expand function for escape sequences.
|
* Fixed a bug in the expand function for escape sequences.
|
||||||
@@ -344,17 +405,17 @@ version 0.4.3 (released 2010-05-18)
|
|||||||
* Fixed sftp_chown.
|
* Fixed sftp_chown.
|
||||||
* Fixed sftp_rename on protocol version 3.
|
* Fixed sftp_rename on protocol version 3.
|
||||||
* Fixed a blocking bug in channel_poll.
|
* Fixed a blocking bug in channel_poll.
|
||||||
* Fixed config parsing wich has overwritten user specified values.
|
* Fixed config parsing which has overwritten user specified values.
|
||||||
* Fixed hashed [host]:port format in knownhosts
|
* Fixed hashed [host]:port format in knownhosts
|
||||||
* Fixed Windows build.
|
* Fixed Windows build.
|
||||||
* Fixed doublefree happening after a negociation error.
|
* Fixed doublefree happening after a negotiation error.
|
||||||
* Fixed aes*-ctr with <= OpenSSL 0.9.7b.
|
* Fixed aes*-ctr with <= OpenSSL 0.9.7b.
|
||||||
* Fixed some documentation.
|
* Fixed some documentation.
|
||||||
* Fixed exec example which has broken read usage.
|
* Fixed exec example which has broken read usage.
|
||||||
* Fixed broken algorithm choice for server.
|
* Fixed broken algorithm choice for server.
|
||||||
* Fixed a typo that we don't export all symbols.
|
* Fixed a typo that we don't export all symbols.
|
||||||
* Removed the unneeded dependency to doxygen.
|
* Removed the unneeded dependency to doxygen.
|
||||||
* Build examples only on the Linux plattform.
|
* Build examples only on the Linux platform.
|
||||||
|
|
||||||
version 0.4.2 (released 2010-03-15)
|
version 0.4.2 (released 2010-03-15)
|
||||||
* Added owner and group information in sftp attributes.
|
* Added owner and group information in sftp attributes.
|
||||||
@@ -376,7 +437,7 @@ version 0.4.1 (released 2010-02-13)
|
|||||||
* Added an example for exec.
|
* Added an example for exec.
|
||||||
* Added private key type detection feature in privatekey_from_file().
|
* Added private key type detection feature in privatekey_from_file().
|
||||||
* Fixed zlib compression fallback.
|
* Fixed zlib compression fallback.
|
||||||
* Fixed kex bug that client preference should be prioritary
|
* Fixed kex bug that client preference should be priority
|
||||||
* Fixed known_hosts file set by the user.
|
* Fixed known_hosts file set by the user.
|
||||||
* Fixed a memleak in channel_accept().
|
* Fixed a memleak in channel_accept().
|
||||||
* Fixed underflow when leave_function() are unbalanced
|
* Fixed underflow when leave_function() are unbalanced
|
||||||
@@ -434,14 +495,6 @@ version 0.3.2 (released 2009-08-05)
|
|||||||
* Fixed compilation on Solaris.
|
* Fixed compilation on Solaris.
|
||||||
* Fixed SSHv1 compilation.
|
* Fixed SSHv1 compilation.
|
||||||
|
|
||||||
version 0.3.1 (released 2009-07-14)
|
|
||||||
* Added return code SSH_SERVER_FILE_NOT_FOUND.
|
|
||||||
* Fixed compilation of SSHv1.
|
|
||||||
* Fixed several memory leaks.
|
|
||||||
* Fixed possible infinite loops.
|
|
||||||
* Fixed a possible crash bug.
|
|
||||||
* Fixed build warnings.
|
|
||||||
* Fixed cmake on BSD.
|
|
||||||
version 0.3.1 (released 2009-07-14)
|
version 0.3.1 (released 2009-07-14)
|
||||||
* Added return code SSH_SERVER_FILE_NOT_FOUND.
|
* Added return code SSH_SERVER_FILE_NOT_FOUND.
|
||||||
* Fixed compilation of SSHv1.
|
* Fixed compilation of SSHv1.
|
||||||
@@ -491,7 +544,7 @@ version 0.2 (released 2007-11-29)
|
|||||||
version 0.11-dev
|
version 0.11-dev
|
||||||
* Server implementation development.
|
* Server implementation development.
|
||||||
* Small bug corrected when connecting to sun ssh servers.
|
* Small bug corrected when connecting to sun ssh servers.
|
||||||
* Channel wierdness corrected (writing huge data packets)
|
* Channel weirdness corrected (writing huge data packets)
|
||||||
* Channel_read_nonblocking added
|
* Channel_read_nonblocking added
|
||||||
* Channel bug where stderr wasn't correctly read fixed.
|
* Channel bug where stderr wasn't correctly read fixed.
|
||||||
* Added sftp_file_set_nonblocking(), which is nonblocking SFTP IO
|
* Added sftp_file_set_nonblocking(), which is nonblocking SFTP IO
|
||||||
@@ -522,7 +575,7 @@ version 0.11-dev
|
|||||||
* Keyboard-interactive authentication working.
|
* Keyboard-interactive authentication working.
|
||||||
|
|
||||||
version 0.1 (released 2004-03-05)
|
version 0.1 (released 2004-03-05)
|
||||||
* Begining of sftp subsystem implementation.
|
* Beginning of sftp subsystem implementation.
|
||||||
* Some cleanup into channels implementation
|
* Some cleanup into channels implementation
|
||||||
* Now every channel functions is called by its CHANNEL handler.
|
* Now every channel functions is called by its CHANNEL handler.
|
||||||
* Added channel_poll() and channel_read().
|
* Added channel_poll() and channel_read().
|
||||||
@@ -543,7 +596,7 @@ version 0.0.4 (released 2003-10-10)
|
|||||||
* Added a wrapper.c file. The goal is to provide a similar API to every
|
* Added a wrapper.c file. The goal is to provide a similar API to every
|
||||||
cryptographic functions. bignums and sha/md5 are wrapped now.
|
cryptographic functions. bignums and sha/md5 are wrapped now.
|
||||||
* More work than it first looks.
|
* More work than it first looks.
|
||||||
* Support for other crypto libs planed (lighter libs)
|
* Support for other crypto libs planned (lighter libs)
|
||||||
* Fixed stupid select() bug.
|
* Fixed stupid select() bug.
|
||||||
* Libssh now compiles and links with openssl 0.9.6
|
* Libssh now compiles and links with openssl 0.9.6
|
||||||
* RSA pubkey authentication code now works !
|
* RSA pubkey authentication code now works !
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.3.0)
|
cmake_minimum_required(VERSION 3.3.0)
|
||||||
cmake_policy(SET CMP0048 NEW)
|
cmake_policy(SET CMP0048 NEW)
|
||||||
|
|
||||||
# Specify search path for CMake modules to be loaded by include()
|
# Specify search path for CMake modules to be loaded by include()
|
||||||
# and find_package()
|
# and find_package()
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
|
|||||||
include(DefineCMakeDefaults)
|
include(DefineCMakeDefaults)
|
||||||
include(DefineCompilerFlags)
|
include(DefineCompilerFlags)
|
||||||
|
|
||||||
project(libssh VERSION 0.9.2 LANGUAGES C)
|
project(libssh VERSION 0.10.6 LANGUAGES C)
|
||||||
|
|
||||||
# global needed variable
|
# global needed variable
|
||||||
set(APPLICATION_NAME ${PROJECT_NAME})
|
set(APPLICATION_NAME ${PROJECT_NAME})
|
||||||
@@ -22,7 +22,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
|
|||||||
# Increment AGE. Set REVISION to 0
|
# Increment AGE. Set REVISION to 0
|
||||||
# If the source code was changed, but there were no interface changes:
|
# If the source code was changed, but there were no interface changes:
|
||||||
# Increment REVISION.
|
# Increment REVISION.
|
||||||
set(LIBRARY_VERSION "4.8.3")
|
set(LIBRARY_VERSION "4.9.6")
|
||||||
set(LIBRARY_SOVERSION "4")
|
set(LIBRARY_SOVERSION "4")
|
||||||
|
|
||||||
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
|
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
|
||||||
@@ -58,8 +58,14 @@ elseif(WITH_MBEDTLS)
|
|||||||
message(FATAL_ERROR "Could not find mbedTLS")
|
message(FATAL_ERROR "Could not find mbedTLS")
|
||||||
endif (NOT MBEDTLS_FOUND)
|
endif (NOT MBEDTLS_FOUND)
|
||||||
else (WITH_GCRYPT)
|
else (WITH_GCRYPT)
|
||||||
find_package(OpenSSL)
|
find_package(OpenSSL 1.0.1)
|
||||||
if (NOT OPENSSL_FOUND)
|
if (OPENSSL_FOUND)
|
||||||
|
# On CMake < 3.16, OPENSSL_CRYPTO_LIBRARIES is usually a synonym for OPENSSL_CRYPTO_LIBRARY, but is not defined
|
||||||
|
# when building on Windows outside of Cygwin. We provide the synonym here, if FindOpenSSL didn't define it already.
|
||||||
|
if (NOT DEFINED OPENSSL_CRYPTO_LIBRARIES)
|
||||||
|
set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
||||||
|
endif (NOT DEFINED OPENSSL_CRYPTO_LIBRARIES)
|
||||||
|
else (OPENSSL_FOUND)
|
||||||
find_package(GCrypt)
|
find_package(GCrypt)
|
||||||
if (NOT GCRYPT_FOUND)
|
if (NOT GCRYPT_FOUND)
|
||||||
find_package(MbedTLS)
|
find_package(MbedTLS)
|
||||||
@@ -67,7 +73,7 @@ else (WITH_GCRYPT)
|
|||||||
message(FATAL_ERROR "Could not find OpenSSL, GCrypt or mbedTLS")
|
message(FATAL_ERROR "Could not find OpenSSL, GCrypt or mbedTLS")
|
||||||
endif (NOT MBEDTLS_FOUND)
|
endif (NOT MBEDTLS_FOUND)
|
||||||
endif (NOT GCRYPT_FOUND)
|
endif (NOT GCRYPT_FOUND)
|
||||||
endif (NOT OPENSSL_FOUND)
|
endif (OPENSSL_FOUND)
|
||||||
endif(WITH_GCRYPT)
|
endif(WITH_GCRYPT)
|
||||||
|
|
||||||
if (UNIT_TESTING)
|
if (UNIT_TESTING)
|
||||||
@@ -83,6 +89,13 @@ if (WITH_GSSAPI)
|
|||||||
find_package(GSSAPI)
|
find_package(GSSAPI)
|
||||||
endif (WITH_GSSAPI)
|
endif (WITH_GSSAPI)
|
||||||
|
|
||||||
|
if (WITH_PKCS11_URI)
|
||||||
|
find_package(softhsm)
|
||||||
|
if (NOT SOFTHSM_FOUND)
|
||||||
|
message(SEND_ERROR "Could not find softhsm module!")
|
||||||
|
endif (NOT SOFTHSM_FOUND)
|
||||||
|
endif (WITH_PKCS11_URI)
|
||||||
|
|
||||||
if (WITH_NACL)
|
if (WITH_NACL)
|
||||||
find_package(NaCl)
|
find_package(NaCl)
|
||||||
if (NOT NACL_FOUND)
|
if (NOT NACL_FOUND)
|
||||||
@@ -90,9 +103,7 @@ if (WITH_NACL)
|
|||||||
endif (NOT NACL_FOUND)
|
endif (NOT NACL_FOUND)
|
||||||
endif (WITH_NACL)
|
endif (WITH_NACL)
|
||||||
|
|
||||||
if (BSD OR SOLARIS OR OSX)
|
find_package(Argp)
|
||||||
find_package(Argp)
|
|
||||||
endif (BSD OR SOLARIS OR OSX)
|
|
||||||
|
|
||||||
# Disable symbol versioning in non UNIX platforms
|
# Disable symbol versioning in non UNIX platforms
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
@@ -111,8 +122,8 @@ add_subdirectory(include)
|
|||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
# pkg-config file
|
# pkg-config file
|
||||||
if (UNIX)
|
if (UNIX OR MINGW)
|
||||||
configure_file(libssh.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh.pc)
|
configure_file(libssh.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh.pc @ONLY)
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/libssh.pc
|
${CMAKE_CURRENT_BINARY_DIR}/libssh.pc
|
||||||
@@ -121,7 +132,7 @@ install(
|
|||||||
COMPONENT
|
COMPONENT
|
||||||
pkgconfig
|
pkgconfig
|
||||||
)
|
)
|
||||||
endif (UNIX)
|
endif (UNIX OR MINGW)
|
||||||
|
|
||||||
# CMake config files
|
# CMake config files
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
@@ -203,10 +214,10 @@ if (WITH_SYMBOL_VERSIONING AND ABIMAP_FOUND)
|
|||||||
endif(UPDATE_ABI)
|
endif(UPDATE_ABI)
|
||||||
endif (WITH_SYMBOL_VERSIONING AND ABIMAP_FOUND)
|
endif (WITH_SYMBOL_VERSIONING AND ABIMAP_FOUND)
|
||||||
|
|
||||||
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source DEPENDS ${_SYMBOL_TARGET})
|
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source DEPENDS ${_SYMBOL_TARGET} VERBATIM)
|
||||||
|
|
||||||
# Link compile database for clangd
|
# Link compile database for clangd
|
||||||
execute_process(COMMAND cmake -E create_symlink
|
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
"${CMAKE_BINARY_DIR}/compile_commands.json"
|
"${CMAKE_BINARY_DIR}/compile_commands.json"
|
||||||
"${CMAKE_SOURCE_DIR}/compile_commands.json")
|
"${CMAKE_SOURCE_DIR}/compile_commands.json")
|
||||||
|
|
||||||
@@ -221,11 +232,14 @@ message(STATUS "SFTP support: ${WITH_SFTP}")
|
|||||||
message(STATUS "Server support : ${WITH_SERVER}")
|
message(STATUS "Server support : ${WITH_SERVER}")
|
||||||
message(STATUS "GSSAPI support : ${WITH_GSSAPI}")
|
message(STATUS "GSSAPI support : ${WITH_GSSAPI}")
|
||||||
message(STATUS "GEX support : ${WITH_GEX}")
|
message(STATUS "GEX support : ${WITH_GEX}")
|
||||||
|
message(STATUS "Support insecure none cipher and MAC : ${WITH_INSECURE_NONE}")
|
||||||
message(STATUS "Pcap debugging support : ${WITH_PCAP}")
|
message(STATUS "Pcap debugging support : ${WITH_PCAP}")
|
||||||
message(STATUS "Build shared library: ${BUILD_SHARED_LIBS}")
|
message(STATUS "Build shared library: ${BUILD_SHARED_LIBS}")
|
||||||
message(STATUS "Unit testing: ${UNIT_TESTING}")
|
message(STATUS "Unit testing: ${UNIT_TESTING}")
|
||||||
message(STATUS "Client code testing: ${CLIENT_TESTING}")
|
message(STATUS "Client code testing: ${CLIENT_TESTING}")
|
||||||
message(STATUS "Blowfish cipher support: ${WITH_BLOWFISH_CIPHER}")
|
message(STATUS "Blowfish cipher support: ${WITH_BLOWFISH_CIPHER}")
|
||||||
|
message(STATUS "PKCS #11 URI support: ${WITH_PKCS11_URI}")
|
||||||
|
message(STATUS "DSA support: ${WITH_DSA}")
|
||||||
set(_SERVER_TESTING OFF)
|
set(_SERVER_TESTING OFF)
|
||||||
if (WITH_SERVER)
|
if (WITH_SERVER)
|
||||||
set(_SERVER_TESTING ${SERVER_TESTING})
|
set(_SERVER_TESTING ${SERVER_TESTING})
|
||||||
|
|||||||
@@ -1,9 +1,126 @@
|
|||||||
Coding conventions in the libssh tree
|
# How to contribute a patch to libssh
|
||||||
======================================
|
|
||||||
|
|
||||||
===========
|
Please checkout the libssh source code using git.
|
||||||
Quick Start
|
|
||||||
===========
|
For contributions we prefer Merge Requests on Gitlab:
|
||||||
|
|
||||||
|
https://gitlab.com/libssh/libssh-mirror/
|
||||||
|
|
||||||
|
This way you get continuous integration which runs the complete libssh
|
||||||
|
testsuite for you.
|
||||||
|
|
||||||
|
For larger code changes, breaking the changes up into a set of simple
|
||||||
|
patches, each of which does a single thing, are much easier to review.
|
||||||
|
Patch sets like that will most likely have an easier time being merged
|
||||||
|
into the libssh code than large single patches that make lots of
|
||||||
|
changes in one large diff.
|
||||||
|
|
||||||
|
Also bugfixes and new features should be covered by tests. We use the cmocka
|
||||||
|
and cwrap framework for our testing and you can simply run it locally by
|
||||||
|
calling `make test`.
|
||||||
|
|
||||||
|
## Ownership of the contributed code
|
||||||
|
|
||||||
|
libssh is a project with distributed copyright ownership, which means
|
||||||
|
we prefer the copyright on parts of libssh to be held by individuals
|
||||||
|
rather than corporations if possible. There are historical legal
|
||||||
|
reasons for this, but one of the best ways to explain it is that it's
|
||||||
|
much easier to work with individuals who have ownership than corporate
|
||||||
|
legal departments if we ever need to make reasonable compromises with
|
||||||
|
people using and working with libssh.
|
||||||
|
|
||||||
|
We track the ownership of every part of libssh via https://git.libssh.org,
|
||||||
|
our source code control system, so we know the provenance of every piece
|
||||||
|
of code that is committed to libssh.
|
||||||
|
|
||||||
|
So if possible, if you're doing libssh changes on behalf of a company
|
||||||
|
who normally owns all the work you do please get them to assign
|
||||||
|
personal copyright ownership of your changes to you as an individual,
|
||||||
|
that makes things very easy for us to work with and avoids bringing
|
||||||
|
corporate legal departments into the picture.
|
||||||
|
|
||||||
|
If you can't do this we can still accept patches from you owned by
|
||||||
|
your employer under a standard employment contract with corporate
|
||||||
|
copyright ownership. It just requires a simple set-up process first.
|
||||||
|
|
||||||
|
We use a process very similar to the way things are done in the Linux
|
||||||
|
Kernel community, so it should be very easy to get a sign off from
|
||||||
|
your corporate legal department. The only changes we've made are to
|
||||||
|
accommodate the license we use, which is LGPLv2 (or later) whereas the
|
||||||
|
Linux kernel uses GPLv2.
|
||||||
|
|
||||||
|
The process is called signing.
|
||||||
|
|
||||||
|
## How to sign your work
|
||||||
|
|
||||||
|
Once you have permission to contribute to libssh from your employer, simply
|
||||||
|
email a copy of the following text from your corporate email address to:
|
||||||
|
|
||||||
|
contributing@libssh.org
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
libssh Developer's Certificate of Origin. Version 1.0
|
||||||
|
|
||||||
|
|
||||||
|
By making a contribution to this project, I certify that:
|
||||||
|
|
||||||
|
(a) The contribution was created in whole or in part by me and I
|
||||||
|
have the right to submit it under the appropriate
|
||||||
|
version of the GNU General Public License; or
|
||||||
|
|
||||||
|
(b) The contribution is based upon previous work that, to the best of
|
||||||
|
my knowledge, is covered under an appropriate open source license
|
||||||
|
and I have the right under that license to submit that work with
|
||||||
|
modifications, whether created in whole or in part by me, under
|
||||||
|
the GNU General Public License, in the appropriate version; or
|
||||||
|
|
||||||
|
(c) The contribution was provided directly to me by some other
|
||||||
|
person who certified (a) or (b) and I have not modified it.
|
||||||
|
|
||||||
|
(d) I understand and agree that this project and the contribution are
|
||||||
|
public and that a record of the contribution (including all
|
||||||
|
metadata and personal information I submit with it, including my
|
||||||
|
sign-off) is maintained indefinitely and may be redistributed
|
||||||
|
consistent with the libssh Team's policies and the requirements of
|
||||||
|
the GNU GPL where they are relevant.
|
||||||
|
|
||||||
|
(e) I am granting this work to this project under the terms of the
|
||||||
|
GNU Lesser General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2.1 of
|
||||||
|
the License, or (at the option of the project) any later version.
|
||||||
|
|
||||||
|
https://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
|
```
|
||||||
|
|
||||||
|
We will maintain a copy of that email as a record that you have the
|
||||||
|
rights to contribute code to libssh under the required licenses whilst
|
||||||
|
working for the company where the email came from.
|
||||||
|
|
||||||
|
Then when sending in a patch via the normal mechanisms described
|
||||||
|
above, add a line that states:
|
||||||
|
|
||||||
|
Signed-off-by: Random J Developer <random@developer.example.org>
|
||||||
|
|
||||||
|
using your real name and the email address you sent the original email
|
||||||
|
you used to send the libssh Developer's Certificate of Origin to us
|
||||||
|
(sorry, no pseudonyms or anonymous contributions.)
|
||||||
|
|
||||||
|
That's it! Such code can then quite happily contain changes that have
|
||||||
|
copyright messages such as:
|
||||||
|
|
||||||
|
(c) Example Corporation.
|
||||||
|
|
||||||
|
and can be merged into the libssh codebase in the same way as patches
|
||||||
|
from any other individual. You don't need to send in a copy of the
|
||||||
|
libssh Developer's Certificate of Origin for each patch, or inside each
|
||||||
|
patch. Just the sign-off message is all that is required once we've
|
||||||
|
received the initial email.
|
||||||
|
|
||||||
|
|
||||||
|
# Coding conventions in the libssh tree
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
Coding style guidelines are about reducing the number of unnecessary
|
Coding style guidelines are about reducing the number of unnecessary
|
||||||
reformatting patches and making things easier for developers to work together.
|
reformatting patches and making things easier for developers to work together.
|
||||||
@@ -36,31 +153,28 @@ are the highlights.
|
|||||||
have a copy of "The C Programming Language" anyways right?
|
have a copy of "The C Programming Language" anyways right?
|
||||||
|
|
||||||
|
|
||||||
=============
|
## Editor Hints
|
||||||
Editor Hints
|
|
||||||
=============
|
### Emacs
|
||||||
|
|
||||||
Emacs
|
|
||||||
------
|
|
||||||
Add the follow to your $HOME/.emacs file:
|
Add the follow to your $HOME/.emacs file:
|
||||||
|
|
||||||
(add-hook 'c-mode-hook
|
(add-hook 'c-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(c-set-style "linux")
|
(c-set-style "linux")
|
||||||
(c-toggle-auto-state)))
|
(c-toggle-auto-state)))
|
||||||
|
|
||||||
|
|
||||||
Vim
|
## Neovim/VIM
|
||||||
----
|
|
||||||
|
|
||||||
For the basic vi editor included with all variants of \*nix, add the
|
For the basic vi editor included with all variants of \*nix, add the
|
||||||
following to $HOME/.vimrc:
|
following to ~/.config/nvim/init.rc or ~/.vimrc:
|
||||||
|
|
||||||
set ts=4 sw=4 et cindent
|
set ts=4 sw=4 et cindent
|
||||||
|
|
||||||
You can use the Vim gitmodline plugin to store this in the git config:
|
You can use the Vim gitmodline plugin to store this in the git config:
|
||||||
|
|
||||||
http://git.cryptomilk.org/projects/vim-gitmodeline.git/
|
https://git.cryptomilk.org/projects/vim-gitmodeline.git/
|
||||||
|
|
||||||
For Vim, the following settings in $HOME/.vimrc will also deal with
|
For Vim, the following settings in $HOME/.vimrc will also deal with
|
||||||
displaying trailing whitespace:
|
displaying trailing whitespace:
|
||||||
@@ -81,12 +195,9 @@ displaying trailing whitespace:
|
|||||||
autocmd BufNewFile,BufRead *.c,*.h exec 'match Todo /\%>' . &textwidth . 'v.\+/'
|
autocmd BufNewFile,BufRead *.c,*.h exec 'match Todo /\%>' . &textwidth . 'v.\+/'
|
||||||
|
|
||||||
|
|
||||||
==========================
|
## FAQ & Statement Reference
|
||||||
FAQ & Statement Reference
|
|
||||||
==========================
|
|
||||||
|
|
||||||
Comments
|
### Comments
|
||||||
---------
|
|
||||||
|
|
||||||
Comments should always use the standard C syntax. C++ style comments are not
|
Comments should always use the standard C syntax. C++ style comments are not
|
||||||
currently allowed.
|
currently allowed.
|
||||||
@@ -163,8 +274,7 @@ This is bad:
|
|||||||
* This is a multi line comment,
|
* This is a multi line comment,
|
||||||
* with some more words...*/
|
* with some more words...*/
|
||||||
|
|
||||||
Indention & Whitespace & 80 columns
|
### Indentation & Whitespace & 80 columns
|
||||||
------------------------------------
|
|
||||||
|
|
||||||
To avoid confusion, indentations have to be 4 spaces. Do not use tabs!. When
|
To avoid confusion, indentations have to be 4 spaces. Do not use tabs!. When
|
||||||
wrapping parameters for function calls, align the parameter list with the first
|
wrapping parameters for function calls, align the parameter list with the first
|
||||||
@@ -180,8 +290,7 @@ splitting. Never split a line before columns 70 - 79 unless you
|
|||||||
have a really good reason. Be smart about formatting.
|
have a really good reason. Be smart about formatting.
|
||||||
|
|
||||||
|
|
||||||
If, switch, & Code blocks
|
### If, switch, & Code blocks
|
||||||
--------------------------
|
|
||||||
|
|
||||||
Always follow an 'if' keyword with a space but don't include additional
|
Always follow an 'if' keyword with a space but don't include additional
|
||||||
spaces following or preceding the parentheses in the conditional.
|
spaces following or preceding the parentheses in the conditional.
|
||||||
@@ -207,7 +316,7 @@ invoking functions.
|
|||||||
Braces for code blocks used by for, if, switch, while, do..while, etc. should
|
Braces for code blocks used by for, if, switch, while, do..while, etc. should
|
||||||
begin on the same line as the statement keyword and end on a line of their own.
|
begin on the same line as the statement keyword and end on a line of their own.
|
||||||
You should always include braces, even if the block only contains one
|
You should always include braces, even if the block only contains one
|
||||||
statement. NOTE: Functions are different and the beginning left brace should
|
statement. **NOTE**: Functions are different and the beginning left brace should
|
||||||
be located in the first column on the next line.
|
be located in the first column on the next line.
|
||||||
|
|
||||||
If the beginning statement has to be broken across lines due to length, the
|
If the beginning statement has to be broken across lines due to length, the
|
||||||
@@ -254,8 +363,7 @@ Bad examples:
|
|||||||
print("I should be in braces.\n");
|
print("I should be in braces.\n");
|
||||||
|
|
||||||
|
|
||||||
Goto
|
### Goto
|
||||||
-----
|
|
||||||
|
|
||||||
While many people have been academically taught that "goto"s are fundamentally
|
While many people have been academically taught that "goto"s are fundamentally
|
||||||
evil, they can greatly enhance readability and reduce memory leaks when used as
|
evil, they can greatly enhance readability and reduce memory leaks when used as
|
||||||
@@ -287,14 +395,13 @@ Good Examples:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Initialize pointers
|
### Initialize pointers
|
||||||
-------------------
|
|
||||||
|
|
||||||
All pointer variables MUST be initialized to NULL. History has
|
All pointer variables **MUST** be initialized to `NULL`. History has
|
||||||
demonstrated that uninitialized pointer variables have lead to various
|
demonstrated that uninitialized pointer variables have lead to various
|
||||||
bugs and security issues.
|
bugs and security issues.
|
||||||
|
|
||||||
Pointers MUST be initialized even if the assignment directly follows
|
Pointers **MUST** be initialized even if the assignment directly follows
|
||||||
the declaration, like pointer2 in the example below, because the
|
the declaration, like pointer2 in the example below, because the
|
||||||
instructions sequence may change over time.
|
instructions sequence may change over time.
|
||||||
|
|
||||||
@@ -309,15 +416,13 @@ Good Example:
|
|||||||
|
|
||||||
pointer1 = some_func1();
|
pointer1 = some_func1();
|
||||||
|
|
||||||
Typedefs
|
### Typedefs
|
||||||
---------
|
|
||||||
|
|
||||||
libssh tries to avoid "typedef struct { .. } x_t;" so we do always try to use
|
libssh tries to avoid `typedef struct { .. } x_t;` so we do always try to use
|
||||||
"struct x { .. };". We know there are still such typedefs in the code, but for
|
`struct x { .. };`. We know there are still such typedefs in the code, but for
|
||||||
new code, please don't do that anymore.
|
new code, please don't do that anymore.
|
||||||
|
|
||||||
Make use of helper variables
|
### Make use of helper variables
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
Please try to avoid passing function calls as function parameters in new code.
|
Please try to avoid passing function calls as function parameters in new code.
|
||||||
This makes the code much easier to read and it's also easier to use the "step"
|
This makes the code much easier to read and it's also easier to use the "step"
|
||||||
@@ -367,9 +472,13 @@ an iterator style:
|
|||||||
But in general, please try to avoid this pattern.
|
But in general, please try to avoid this pattern.
|
||||||
|
|
||||||
|
|
||||||
Control-Flow changing macros
|
### Control-Flow changing macros
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
Macros like STATUS_NOT_OK_RETURN that change control flow (return/goto/etc)
|
Macros like `STATUS_NOT_OK_RETURN` that change control flow (return/goto/etc)
|
||||||
from within the macro are considered bad, because they look like function calls
|
from within the macro are considered bad, because they look like function calls
|
||||||
that never change control flow. Please do not introduce them.
|
that never change control flow. Please do not introduce them.
|
||||||
|
|
||||||
|
|
||||||
|
Have fun and happy libssh hacking!
|
||||||
|
|
||||||
|
The libssh Team
|
||||||
@@ -10,7 +10,7 @@ set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
|
|||||||
|
|
||||||
# SOURCE GENERATOR
|
# SOURCE GENERATOR
|
||||||
set(CPACK_SOURCE_GENERATOR "TXZ")
|
set(CPACK_SOURCE_GENERATOR "TXZ")
|
||||||
set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]git/;/[.]clangd/;.gitignore;/build*;/obj*;tags;cscope.*;compile_commands.json")
|
set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]git;/[.]clangd/;/[.]cache/;.gitignore;/build*;/obj*;tags;cscope.*;compile_commands.json;.*\.patch")
|
||||||
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
### NSIS INSTALLER
|
### NSIS INSTALLER
|
||||||
@@ -23,7 +23,7 @@ if (WIN32)
|
|||||||
set(CPACK_GENERATOR "${CPACK_GENERATOR};NSIS")
|
set(CPACK_GENERATOR "${CPACK_GENERATOR};NSIS")
|
||||||
set(CPACK_NSIS_DISPLAY_NAME "The SSH Library")
|
set(CPACK_NSIS_DISPLAY_NAME "The SSH Library")
|
||||||
set(CPACK_NSIS_COMPRESSOR "/SOLID zlib")
|
set(CPACK_NSIS_COMPRESSOR "/SOLID zlib")
|
||||||
set(CPACK_NSIS_MENU_LINKS "http://www.libssh.org/" "libssh homepage")
|
set(CPACK_NSIS_MENU_LINKS "https://www.libssh.org/" "libssh homepage")
|
||||||
endif (NSIS_MAKE)
|
endif (NSIS_MAKE)
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ if (UNIX)
|
|||||||
add_c_compiler_flag("-Wstrict-overflow=2" SUPPORTED_COMPILER_FLAGS)
|
add_c_compiler_flag("-Wstrict-overflow=2" SUPPORTED_COMPILER_FLAGS)
|
||||||
add_c_compiler_flag("-Wno-format-zero-length" SUPPORTED_COMPILER_FLAGS)
|
add_c_compiler_flag("-Wno-format-zero-length" SUPPORTED_COMPILER_FLAGS)
|
||||||
add_c_compiler_flag("-Wmissing-field-initializers" SUPPORTED_COMPILER_FLAGS)
|
add_c_compiler_flag("-Wmissing-field-initializers" SUPPORTED_COMPILER_FLAGS)
|
||||||
|
add_c_compiler_flag("-Wsign-compare" SUPPORTED_COMPILER_FLAGS)
|
||||||
|
|
||||||
check_c_compiler_flag("-Wformat" REQUIRED_FLAGS_WFORMAT)
|
check_c_compiler_flag("-Wformat" REQUIRED_FLAGS_WFORMAT)
|
||||||
if (REQUIRED_FLAGS_WFORMAT)
|
if (REQUIRED_FLAGS_WFORMAT)
|
||||||
@@ -69,7 +70,7 @@ if (UNIX)
|
|||||||
check_c_compiler_flag_ssp("-fstack-protector-strong" WITH_STACK_PROTECTOR_STRONG)
|
check_c_compiler_flag_ssp("-fstack-protector-strong" WITH_STACK_PROTECTOR_STRONG)
|
||||||
if (WITH_STACK_PROTECTOR_STRONG)
|
if (WITH_STACK_PROTECTOR_STRONG)
|
||||||
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector-strong")
|
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector-strong")
|
||||||
# This is needed as Solaris has a seperate libssp
|
# This is needed as Solaris has a separate libssp
|
||||||
if (SOLARIS)
|
if (SOLARIS)
|
||||||
list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector-strong")
|
list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector-strong")
|
||||||
endif()
|
endif()
|
||||||
@@ -77,16 +78,18 @@ if (UNIX)
|
|||||||
check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
|
check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
|
||||||
if (WITH_STACK_PROTECTOR)
|
if (WITH_STACK_PROTECTOR)
|
||||||
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector")
|
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector")
|
||||||
# This is needed as Solaris has a seperate libssp
|
# This is needed as Solaris has a separate libssp
|
||||||
if (SOLARIS)
|
if (SOLARIS)
|
||||||
list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector")
|
list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif (WITH_STACK_PROTECTOR_STRONG)
|
endif (WITH_STACK_PROTECTOR_STRONG)
|
||||||
|
|
||||||
check_c_compiler_flag_ssp("-fstack-clash-protection" WITH_STACK_CLASH_PROTECTION)
|
if (NOT WINDOWS AND NOT CYGWIN)
|
||||||
if (WITH_STACK_CLASH_PROTECTION)
|
check_c_compiler_flag_ssp("-fstack-clash-protection" WITH_STACK_CLASH_PROTECTION)
|
||||||
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-clash-protection")
|
if (WITH_STACK_CLASH_PROTECTION)
|
||||||
|
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-clash-protection")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (PICKY_DEVELOPER)
|
if (PICKY_DEVELOPER)
|
||||||
|
|||||||
@@ -101,62 +101,50 @@ if (OPENSSL_FOUND)
|
|||||||
check_include_file(openssl/ecdsa.h HAVE_OPENSSL_ECDSA_H)
|
check_include_file(openssl/ecdsa.h HAVE_OPENSSL_ECDSA_H)
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
check_function_exists(EVP_aes_128_ctr HAVE_OPENSSL_EVP_AES_CTR)
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
|
||||||
check_function_exists(EVP_aes_128_cbc HAVE_OPENSSL_EVP_AES_CBC)
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
|
||||||
check_function_exists(EVP_aes_128_gcm HAVE_OPENSSL_EVP_AES_GCM)
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
|
||||||
check_function_exists(CRYPTO_THREADID_set_callback HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK)
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
|
||||||
check_function_exists(CRYPTO_ctr128_encrypt HAVE_OPENSSL_CRYPTO_CTR128_ENCRYPT)
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
|
||||||
check_function_exists(EVP_CIPHER_CTX_new HAVE_OPENSSL_EVP_CIPHER_CTX_NEW)
|
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
|
||||||
check_function_exists(EVP_KDF_CTX_new_id HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID)
|
check_function_exists(EVP_KDF_CTX_new_id HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID)
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
|
check_function_exists(EVP_KDF_CTX_new HAVE_OPENSSL_EVP_KDF_CTX_NEW)
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
check_function_exists(FIPS_mode HAVE_OPENSSL_FIPS_MODE)
|
check_function_exists(FIPS_mode HAVE_OPENSSL_FIPS_MODE)
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
check_function_exists(RAND_priv_bytes HAVE_OPENSSL_RAND_PRIV_BYTES)
|
check_function_exists(RAND_priv_bytes HAVE_OPENSSL_RAND_PRIV_BYTES)
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
check_function_exists(EVP_DigestSign HAVE_OPENSSL_EVP_DIGESTSIGN)
|
check_function_exists(EVP_DigestSign HAVE_OPENSSL_EVP_DIGESTSIGN)
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
check_function_exists(EVP_DigestVerify HAVE_OPENSSL_EVP_DIGESTVERIFY)
|
check_function_exists(EVP_DigestVerify HAVE_OPENSSL_EVP_DIGESTVERIFY)
|
||||||
|
|
||||||
check_function_exists(OPENSSL_ia32cap_loc HAVE_OPENSSL_IA32CAP_LOC)
|
check_function_exists(OPENSSL_ia32cap_loc HAVE_OPENSSL_IA32CAP_LOC)
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
check_symbol_exists(EVP_PKEY_ED25519 "openssl/evp.h" FOUND_OPENSSL_ED25519)
|
check_symbol_exists(EVP_PKEY_ED25519 "openssl/evp.h" FOUND_OPENSSL_ED25519)
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
|
check_function_exists(EVP_chacha20 HAVE_OPENSSL_EVP_CHACHA20)
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
|
check_symbol_exists(EVP_PKEY_POLY1305 "openssl/evp.h" HAVE_OPENSSL_EVP_POLY1305)
|
||||||
|
|
||||||
if (HAVE_OPENSSL_EVP_DIGESTSIGN AND HAVE_OPENSSL_EVP_DIGESTVERIFY AND
|
if (HAVE_OPENSSL_EVP_DIGESTSIGN AND HAVE_OPENSSL_EVP_DIGESTVERIFY AND
|
||||||
FOUND_OPENSSL_ED25519)
|
FOUND_OPENSSL_ED25519)
|
||||||
set(HAVE_OPENSSL_ED25519 1)
|
set(HAVE_OPENSSL_ED25519 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
|
||||||
check_symbol_exists(EVP_PKEY_X25519 "openssl/evp.h" HAVE_OPENSSL_X25519)
|
check_symbol_exists(EVP_PKEY_X25519 "openssl/evp.h" HAVE_OPENSSL_X25519)
|
||||||
|
|
||||||
unset(CMAKE_REQUIRED_INCLUDES)
|
unset(CMAKE_REQUIRED_INCLUDES)
|
||||||
@@ -175,11 +163,18 @@ if (NOT WITH_GCRYPT AND NOT WITH_MBEDTLS)
|
|||||||
if (HAVE_OPENSSL_ECC)
|
if (HAVE_OPENSSL_ECC)
|
||||||
set(HAVE_ECC 1)
|
set(HAVE_ECC 1)
|
||||||
endif (HAVE_OPENSSL_ECC)
|
endif (HAVE_OPENSSL_ECC)
|
||||||
|
|
||||||
|
if (HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID OR HAVE_OPENSSL_EVP_KDF_CTX_NEW)
|
||||||
|
set(HAVE_OPENSSL_EVP_KDF_CTX 1)
|
||||||
|
endif (HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID OR HAVE_OPENSSL_EVP_KDF_CTX_NEW)
|
||||||
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (NOT WITH_MBEDTLS)
|
if (WITH_DSA)
|
||||||
set(HAVE_DSA 1)
|
if (NOT WITH_MBEDTLS)
|
||||||
endif (NOT WITH_MBEDTLS)
|
set(HAVE_DSA 1)
|
||||||
|
endif (NOT WITH_MBEDTLS)
|
||||||
|
endif()
|
||||||
|
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
|
|
||||||
@@ -278,11 +273,20 @@ if (GCRYPT_FOUND)
|
|||||||
set(HAVE_GCRYPT_ECC 1)
|
set(HAVE_GCRYPT_ECC 1)
|
||||||
set(HAVE_ECC 1)
|
set(HAVE_ECC 1)
|
||||||
endif (GCRYPT_VERSION VERSION_GREATER "1.4.6")
|
endif (GCRYPT_VERSION VERSION_GREATER "1.4.6")
|
||||||
|
if (NOT GCRYPT_VERSION VERSION_LESS "1.7.0")
|
||||||
|
set(HAVE_GCRYPT_CHACHA_POLY 1)
|
||||||
|
endif (NOT GCRYPT_VERSION VERSION_LESS "1.7.0")
|
||||||
endif (GCRYPT_FOUND)
|
endif (GCRYPT_FOUND)
|
||||||
|
|
||||||
if (MBEDTLS_FOUND)
|
if (MBEDTLS_FOUND)
|
||||||
set(HAVE_LIBMBEDCRYPTO 1)
|
set(HAVE_LIBMBEDCRYPTO 1)
|
||||||
set(HAVE_ECC 1)
|
set(HAVE_ECC 1)
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_INCLUDES "${MBEDTLS_INCLUDE_DIR}/mbedtls")
|
||||||
|
check_include_file(chacha20.h HAVE_MBEDTLS_CHACHA20_H)
|
||||||
|
check_include_file(poly1305.h HAVE_MBEDTLS_POLY1305_H)
|
||||||
|
unset(CMAKE_REQUIRED_INCLUDES)
|
||||||
|
|
||||||
endif (MBEDTLS_FOUND)
|
endif (MBEDTLS_FOUND)
|
||||||
|
|
||||||
if (CMAKE_USE_PTHREADS_INIT)
|
if (CMAKE_USE_PTHREADS_INIT)
|
||||||
@@ -316,7 +320,7 @@ int main(void) {
|
|||||||
# For detecting attributes we need to treat warnings as
|
# For detecting attributes we need to treat warnings as
|
||||||
# errors
|
# errors
|
||||||
if (UNIX OR MINGW)
|
if (UNIX OR MINGW)
|
||||||
# Get warnings for attributs
|
# Get warnings for attributes
|
||||||
check_c_compiler_flag("-Wattributes" REQUIRED_FLAGS_WERROR)
|
check_c_compiler_flag("-Wattributes" REQUIRED_FLAGS_WERROR)
|
||||||
if (REQUIRED_FLAGS_WERROR)
|
if (REQUIRED_FLAGS_WERROR)
|
||||||
string(APPEND CMAKE_REQUIRED_FLAGS "-Wattributes ")
|
string(APPEND CMAKE_REQUIRED_FLAGS "-Wattributes ")
|
||||||
@@ -371,6 +375,23 @@ int main(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}" HAVE_FALLTHROUGH_ATTRIBUTE)
|
}" HAVE_FALLTHROUGH_ATTRIBUTE)
|
||||||
|
|
||||||
|
check_c_source_compiles("
|
||||||
|
#define WEAK __attribute__((weak))
|
||||||
|
|
||||||
|
WEAK int sum(int a, int b)
|
||||||
|
{
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int i = sum(2, 2);
|
||||||
|
|
||||||
|
(void)i;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}" HAVE_WEAK_ATTRIBUTE)
|
||||||
|
|
||||||
if (NOT WIN32)
|
if (NOT WIN32)
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#define __unused __attribute__((unused))
|
#define __unused __attribute__((unused))
|
||||||
@@ -464,6 +485,28 @@ if (WITH_GSSAPI AND NOT GSSAPI_FOUND)
|
|||||||
set(WITH_GSSAPI 0)
|
set(WITH_GSSAPI 0)
|
||||||
endif (WITH_GSSAPI AND NOT GSSAPI_FOUND)
|
endif (WITH_GSSAPI AND NOT GSSAPI_FOUND)
|
||||||
|
|
||||||
|
if (WITH_PKCS11_URI)
|
||||||
|
if (WITH_GCRYPT)
|
||||||
|
message(FATAL_ERROR "PKCS #11 is not supported for gcrypt.")
|
||||||
|
set(WITH_PKCS11_URI 0)
|
||||||
|
endif()
|
||||||
|
if (WITH_MBEDTLS)
|
||||||
|
message(FATAL_ERROR "PKCS #11 is not supported for mbedcrypto")
|
||||||
|
set(WITH_PKCS11_URI 0)
|
||||||
|
endif()
|
||||||
|
if (HAVE_OPENSSL AND NOT OPENSSL_VERSION VERSION_GREATER_EQUAL "1.1.1")
|
||||||
|
message(FATAL_ERROR "PKCS #11 requires at least OpenSSL 1.1.1")
|
||||||
|
set(WITH_PKCS11_URI 0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WITH_MBEDTLS)
|
||||||
|
if (WITH_DSA)
|
||||||
|
message(FATAL_ERROR "DSA is not supported with mbedTLS crypto")
|
||||||
|
set(HAVE_DSA 0)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# ENDIAN
|
# ENDIAN
|
||||||
if (NOT WIN32)
|
if (NOT WIN32)
|
||||||
test_big_endian(WORDS_BIGENDIAN)
|
test_big_endian(WORDS_BIGENDIAN)
|
||||||
|
|||||||
@@ -2,25 +2,28 @@ option(WITH_GSSAPI "Build with GSSAPI support" ON)
|
|||||||
option(WITH_ZLIB "Build with ZLIB support" ON)
|
option(WITH_ZLIB "Build with ZLIB support" ON)
|
||||||
option(WITH_SFTP "Build with SFTP support" ON)
|
option(WITH_SFTP "Build with SFTP support" ON)
|
||||||
option(WITH_SERVER "Build with SSH server support" ON)
|
option(WITH_SERVER "Build with SSH server support" ON)
|
||||||
option(WITH_DEBUG_CRYPTO "Build with cryto debug output" OFF)
|
option(WITH_DEBUG_CRYPTO "Build with crypto debug output" OFF)
|
||||||
option(WITH_DEBUG_PACKET "Build with packet debug output" OFF)
|
option(WITH_DEBUG_PACKET "Build with packet debug output" OFF)
|
||||||
option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON)
|
option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON)
|
||||||
|
option(WITH_DSA "Build with DSA" OFF)
|
||||||
option(WITH_GCRYPT "Compile against libgcrypt" OFF)
|
option(WITH_GCRYPT "Compile against libgcrypt" OFF)
|
||||||
option(WITH_MBEDTLS "Compile against libmbedtls" OFF)
|
option(WITH_MBEDTLS "Compile against libmbedtls" OFF)
|
||||||
option(WITH_BLOWFISH_CIPHER "Compile with blowfish support" OFF)
|
option(WITH_BLOWFISH_CIPHER "Compile with blowfish support" OFF)
|
||||||
option(WITH_PCAP "Compile with Pcap generation support" ON)
|
option(WITH_PCAP "Compile with Pcap generation support" ON)
|
||||||
option(WITH_INTERNAL_DOC "Compile doxygen internal documentation" OFF)
|
option(WITH_INTERNAL_DOC "Compile doxygen internal documentation" OFF)
|
||||||
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||||
|
option(WITH_PKCS11_URI "Build with PKCS#11 URI support" OFF)
|
||||||
option(UNIT_TESTING "Build with unit tests" OFF)
|
option(UNIT_TESTING "Build with unit tests" OFF)
|
||||||
option(CLIENT_TESTING "Build with client tests; requires openssh" OFF)
|
option(CLIENT_TESTING "Build with client tests; requires openssh" OFF)
|
||||||
option(SERVER_TESTING "Build with server tests; requires openssh and dropbear" OFF)
|
option(SERVER_TESTING "Build with server tests; requires openssh and dropbear" OFF)
|
||||||
option(WITH_BENCHMARKS "Build benchmarks tools" OFF)
|
option(WITH_BENCHMARKS "Build benchmarks tools; enables unit testing and client tests" OFF)
|
||||||
option(WITH_EXAMPLES "Build examples" ON)
|
option(WITH_EXAMPLES "Build examples" ON)
|
||||||
option(WITH_NACL "Build with libnacl (curve25519)" ON)
|
option(WITH_NACL "Build with libnacl (curve25519)" ON)
|
||||||
option(WITH_SYMBOL_VERSIONING "Build with symbol versioning" ON)
|
option(WITH_SYMBOL_VERSIONING "Build with symbol versioning" ON)
|
||||||
option(WITH_ABI_BREAK "Allow ABI break" OFF)
|
option(WITH_ABI_BREAK "Allow ABI break" OFF)
|
||||||
option(WITH_GEX "Enable DH Group exchange mechanisms" ON)
|
option(WITH_GEX "Enable DH Group exchange mechanisms" ON)
|
||||||
option(FUZZ_TESTING "Build with fuzzer for the server" OFF)
|
option(WITH_INSECURE_NONE "Enable insecure none cipher and MAC algorithms (not suitable for production!)" OFF)
|
||||||
|
option(FUZZ_TESTING "Build with fuzzer for the server and client (automatically enables none cipher!)" OFF)
|
||||||
option(PICKY_DEVELOPER "Build with picky developer flags" OFF)
|
option(PICKY_DEVELOPER "Build with picky developer flags" OFF)
|
||||||
|
|
||||||
if (WITH_ZLIB)
|
if (WITH_ZLIB)
|
||||||
@@ -53,3 +56,7 @@ endif (NOT GLOBAL_BIND_CONFIG)
|
|||||||
if (NOT GLOBAL_CLIENT_CONFIG)
|
if (NOT GLOBAL_CLIENT_CONFIG)
|
||||||
set(GLOBAL_CLIENT_CONFIG "/etc/ssh/ssh_config")
|
set(GLOBAL_CLIENT_CONFIG "/etc/ssh/ssh_config")
|
||||||
endif (NOT GLOBAL_CLIENT_CONFIG)
|
endif (NOT GLOBAL_CLIENT_CONFIG)
|
||||||
|
|
||||||
|
if (FUZZ_TESTING)
|
||||||
|
set(WITH_INSECURE_NONE ON)
|
||||||
|
endif (FUZZ_TESTING)
|
||||||
|
|||||||
13
INSTALL
13
INSTALL
@@ -7,11 +7,11 @@
|
|||||||
In order to build libssh, you need to install several components:
|
In order to build libssh, you need to install several components:
|
||||||
|
|
||||||
- A C compiler
|
- A C compiler
|
||||||
- [CMake](http://www.cmake.org) >= 2.6.0.
|
- [CMake](https://www.cmake.org) >= 3.3.0
|
||||||
- [openssl](http://www.openssl.org) >= 0.9.8
|
- [openssl](https://www.openssl.org) >= 1.0.1
|
||||||
or
|
or
|
||||||
- [gcrypt](http://www.gnu.org/directory/Security/libgcrypt.html) >= 1.4
|
- [gcrypt](https://www.gnu.org/directory/Security/libgcrypt.html) >= 1.4
|
||||||
- [libz](http://www.zlib.net) >= 1.2
|
- [libz](https://www.zlib.net) >= 1.2
|
||||||
|
|
||||||
optional:
|
optional:
|
||||||
- [cmocka](https://cmocka.org/) >= 1.1.0
|
- [cmocka](https://cmocka.org/) >= 1.1.0
|
||||||
@@ -19,6 +19,7 @@ optional:
|
|||||||
- [nss_wrapper](https://cwrap.org/) >= 1.1.2
|
- [nss_wrapper](https://cwrap.org/) >= 1.1.2
|
||||||
- [uid_wrapper](https://cwrap.org/) >= 1.2.0
|
- [uid_wrapper](https://cwrap.org/) >= 1.2.0
|
||||||
- [pam_wrapper](https://cwrap.org/) >= 1.0.1
|
- [pam_wrapper](https://cwrap.org/) >= 1.0.1
|
||||||
|
- [priv_wrapper](https://cwrap.org/) >= 1.0.0
|
||||||
|
|
||||||
Note that these version numbers are version we know works correctly. If you
|
Note that these version numbers are version we know works correctly. If you
|
||||||
build and run libssh successfully with an older version, please let us know.
|
build and run libssh successfully with an older version, please let us know.
|
||||||
@@ -39,7 +40,7 @@ GNU/Linux, MacOS X, MSYS/MinGW:
|
|||||||
cmake -DUNIT_TESTING=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
|
cmake -DUNIT_TESTING=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
make
|
make
|
||||||
|
|
||||||
On Windows you should choose a makefile gernerator with -G or use
|
On Windows you should choose a makefile generator with -G or use
|
||||||
|
|
||||||
cmake-gui.exe ..
|
cmake-gui.exe ..
|
||||||
|
|
||||||
@@ -117,4 +118,4 @@ This document is written using [Markdown][] syntax, making it possible to
|
|||||||
provide usable information in both plain text and HTML format. Whenever
|
provide usable information in both plain text and HTML format. Whenever
|
||||||
modifying this document please use [Markdown][] syntax.
|
modifying this document please use [Markdown][] syntax.
|
||||||
|
|
||||||
[markdown]: http://www.daringfireball.net/projects/markdown
|
[markdown]: https://www.daringfireball.net/projects/markdown
|
||||||
|
|||||||
4
README
4
README
@@ -31,12 +31,12 @@ If you ask yourself how to compile libssh, please read INSTALL before anything.
|
|||||||
3* Where ?
|
3* Where ?
|
||||||
-_-_-_-_-_-_
|
-_-_-_-_-_-_
|
||||||
|
|
||||||
http://www.libssh.org
|
https://www.libssh.org
|
||||||
|
|
||||||
4* Contributing
|
4* Contributing
|
||||||
-_-_-_-_-_-_-_-_-_
|
-_-_-_-_-_-_-_-_-_
|
||||||
|
|
||||||
Please read the file 'SubmittingPatches' next to this README file. It explains
|
Please read the file 'CONTRIBUTING.md' next to this README file. It explains
|
||||||
our copyright policy and how you should send patches for upstream inclusion.
|
our copyright policy and how you should send patches for upstream inclusion.
|
||||||
|
|
||||||
Have fun and happy libssh hacking!
|
Have fun and happy libssh hacking!
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
[](https://gitlab.com/libssh/libssh-mirror/commits/master)
|
[](https://gitlab.com/libssh/libssh-mirror/commits/master)
|
||||||
|
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:libssh)
|
||||||
|
|
||||||
```
|
```
|
||||||
_ _ _ _
|
_ _ _ _
|
||||||
@@ -36,7 +37,7 @@ https://www.libssh.org
|
|||||||
|
|
||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
Please read the file 'SubmittingPatches' next to this README file. It explains
|
Please read the file 'CONTRIBUTING.md' next to this README file. It explains
|
||||||
our copyright policy and how you should send patches for upstream inclusion.
|
our copyright policy and how you should send patches for upstream inclusion.
|
||||||
|
|
||||||
Have fun and happy libssh hacking!
|
Have fun and happy libssh hacking!
|
||||||
|
|||||||
@@ -1,118 +0,0 @@
|
|||||||
How to contribute a patch to libssh
|
|
||||||
====================================
|
|
||||||
|
|
||||||
Please checkout the libssh source code using git. Change the code and then
|
|
||||||
use "git format-patch" to create a patch. The patch should be signed (see
|
|
||||||
below) and send it to libssh@libssh.org, or attach it to a bug report at
|
|
||||||
https://red.libssh.org/
|
|
||||||
|
|
||||||
For larger code changes, breaking the changes up into a set of simple
|
|
||||||
patches, each of which does a single thing, are much easier to review.
|
|
||||||
Patch sets like that will most likely have an easier time being merged
|
|
||||||
into the libssh code than large single patches that make lots of
|
|
||||||
changes in one large diff.
|
|
||||||
|
|
||||||
Ownership of the contributed code
|
|
||||||
==================================
|
|
||||||
|
|
||||||
libssh is a project with distributed copyright ownership, which means
|
|
||||||
we prefer the copyright on parts of libssh to be held by individuals
|
|
||||||
rather than corporations if possible. There are historical legal
|
|
||||||
reasons for this, but one of the best ways to explain it is that it's
|
|
||||||
much easier to work with individuals who have ownership than corporate
|
|
||||||
legal departments if we ever need to make reasonable compromises with
|
|
||||||
people using and working with libssh.
|
|
||||||
|
|
||||||
We track the ownership of every part of libssh via http://git.libssh.org,
|
|
||||||
our source code control system, so we know the provenance of every piece
|
|
||||||
of code that is committed to libssh.
|
|
||||||
|
|
||||||
So if possible, if you're doing libssh changes on behalf of a company
|
|
||||||
who normally owns all the work you do please get them to assign
|
|
||||||
personal copyright ownership of your changes to you as an individual,
|
|
||||||
that makes things very easy for us to work with and avoids bringing
|
|
||||||
corporate legal departments into the picture.
|
|
||||||
|
|
||||||
If you can't do this we can still accept patches from you owned by
|
|
||||||
your employer under a standard employment contract with corporate
|
|
||||||
copyright ownership. It just requires a simple set-up process first.
|
|
||||||
|
|
||||||
We use a process very similar to the way things are done in the Linux
|
|
||||||
Kernel community, so it should be very easy to get a sign off from
|
|
||||||
your corporate legal department. The only changes we've made are to
|
|
||||||
accommodate the license we use, which is LGPLv2 (or later) whereas the
|
|
||||||
Linux kernel uses GPLv2.
|
|
||||||
|
|
||||||
The process is called signing.
|
|
||||||
|
|
||||||
How to sign your work
|
|
||||||
----------------------
|
|
||||||
|
|
||||||
Once you have permission to contribute to libssh from your employer, simply
|
|
||||||
email a copy of the following text from your corporate email address to:
|
|
||||||
|
|
||||||
contributing@libssh.org
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
libssh Developer's Certificate of Origin. Version 1.0
|
|
||||||
|
|
||||||
|
|
||||||
By making a contribution to this project, I certify that:
|
|
||||||
|
|
||||||
(a) The contribution was created in whole or in part by me and I
|
|
||||||
have the right to submit it under the appropriate
|
|
||||||
version of the GNU General Public License; or
|
|
||||||
|
|
||||||
(b) The contribution is based upon previous work that, to the best of
|
|
||||||
my knowledge, is covered under an appropriate open source license
|
|
||||||
and I have the right under that license to submit that work with
|
|
||||||
modifications, whether created in whole or in part by me, under
|
|
||||||
the GNU General Public License, in the appropriate version; or
|
|
||||||
|
|
||||||
(c) The contribution was provided directly to me by some other
|
|
||||||
person who certified (a) or (b) and I have not modified it.
|
|
||||||
|
|
||||||
(d) I understand and agree that this project and the contribution are
|
|
||||||
public and that a record of the contribution (including all
|
|
||||||
metadata and personal information I submit with it, including my
|
|
||||||
sign-off) is maintained indefinitely and may be redistributed
|
|
||||||
consistent with the libssh Team's policies and the requirements of
|
|
||||||
the GNU GPL where they are relevant.
|
|
||||||
|
|
||||||
(e) I am granting this work to this project under the terms of the
|
|
||||||
GNU Lesser General Public License as published by the
|
|
||||||
Free Software Foundation; either version 2.1 of
|
|
||||||
the License, or (at the option of the project) any later version.
|
|
||||||
|
|
||||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
|
||||||
|
|
||||||
|
|
||||||
We will maintain a copy of that email as a record that you have the
|
|
||||||
rights to contribute code to libssh under the required licenses whilst
|
|
||||||
working for the company where the email came from.
|
|
||||||
|
|
||||||
Then when sending in a patch via the normal mechanisms described
|
|
||||||
above, add a line that states:
|
|
||||||
|
|
||||||
Signed-off-by: Random J Developer <random@developer.example.org>
|
|
||||||
|
|
||||||
using your real name and the email address you sent the original email
|
|
||||||
you used to send the libssh Developer's Certificate of Origin to us
|
|
||||||
(sorry, no pseudonyms or anonymous contributions.)
|
|
||||||
|
|
||||||
That's it! Such code can then quite happily contain changes that have
|
|
||||||
copyright messages such as:
|
|
||||||
|
|
||||||
(c) Example Corporation.
|
|
||||||
|
|
||||||
and can be merged into the libssh codebase in the same way as patches
|
|
||||||
from any other individual. You don't need to send in a copy of the
|
|
||||||
libssh Developer's Certificate of Origin for each patch, or inside each
|
|
||||||
patch. Just the sign-off message is all that is required once we've
|
|
||||||
received the initial email.
|
|
||||||
|
|
||||||
Have fun and happy libssh hacking !
|
|
||||||
|
|
||||||
The libssh Team
|
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|||||||
|
|
||||||
# Put the include dirs which are in the source or build tree
|
# Put the include dirs which are in the source or build tree
|
||||||
# before all other include dirs, so the headers in the sources
|
# before all other include dirs, so the headers in the sources
|
||||||
# are prefered over the already installed ones
|
# are preferred over the already installed ones
|
||||||
# since cmake 2.4.1
|
# since cmake 2.4.1
|
||||||
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
|
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
|
||||||
|
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ if (UNIX AND NOT WIN32)
|
|||||||
CACHE STRING "Flags used by the linker during MEMORYSANITIZER builds.")
|
CACHE STRING "Flags used by the linker during MEMORYSANITIZER builds.")
|
||||||
|
|
||||||
# Activate with: -DCMAKE_BUILD_TYPE=UndefinedSanitizer
|
# Activate with: -DCMAKE_BUILD_TYPE=UndefinedSanitizer
|
||||||
set(CMAKE_C_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover"
|
set(CMAKE_C_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover=undefined,integer"
|
||||||
CACHE STRING "Flags used by the C compiler during UNDEFINEDSANITIZER builds.")
|
CACHE STRING "Flags used by the C compiler during UNDEFINEDSANITIZER builds.")
|
||||||
set(CMAKE_CXX_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover"
|
set(CMAKE_CXX_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover=undefined,integer"
|
||||||
CACHE STRING "Flags used by the CXX compiler during UNDEFINEDSANITIZER builds.")
|
CACHE STRING "Flags used by the CXX compiler during UNDEFINEDSANITIZER builds.")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
|
set(CMAKE_SHARED_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
|
||||||
CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.")
|
CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.")
|
||||||
|
|||||||
@@ -302,12 +302,13 @@ function(get_file_list _TARGET_NAME)
|
|||||||
add_custom_target(
|
add_custom_target(
|
||||||
${_TARGET_NAME}_int ALL
|
${_TARGET_NAME}_int ALL
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-DOUTPUT_PATH="${_get_files_list_OUTPUT_PATH}"
|
-DOUTPUT_PATH=${_get_files_list_OUTPUT_PATH}
|
||||||
-DDIRECTORIES="${_get_files_list_DIRECTORIES}"
|
-DDIRECTORIES=${_get_files_list_DIRECTORIES}
|
||||||
-DFILES_PATTERNS="${_get_files_list_FILES_PATTERNS}"
|
-DFILES_PATTERNS=${_get_files_list_FILES_PATTERNS}
|
||||||
-P ${_GET_FILES_LIST_SCRIPT}
|
-P ${_GET_FILES_LIST_SCRIPT}
|
||||||
COMMENT
|
COMMENT
|
||||||
"Searching for files"
|
"Searching for files"
|
||||||
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
|
||||||
if (DEFINED _get_files_list_COPY_TO)
|
if (DEFINED _get_files_list_COPY_TO)
|
||||||
@@ -318,6 +319,7 @@ function(get_file_list _TARGET_NAME)
|
|||||||
${_FILES_LIST_OUTPUT_PATH} ${_get_files_list_COPY_TO}
|
${_FILES_LIST_OUTPUT_PATH} ${_get_files_list_COPY_TO}
|
||||||
DEPENDS ${_TARGET_NAME}_int
|
DEPENDS ${_TARGET_NAME}_int
|
||||||
COMMENT "Copying ${_TARGET_NAME} to ${_get_files_list_COPY_TO}"
|
COMMENT "Copying ${_TARGET_NAME} to ${_get_files_list_COPY_TO}"
|
||||||
|
VERBATIM
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_custom_target(${_TARGET_NAME} ALL
|
add_custom_target(${_TARGET_NAME} ALL
|
||||||
@@ -369,12 +371,13 @@ function(extract_symbols _TARGET_NAME)
|
|||||||
add_custom_target(
|
add_custom_target(
|
||||||
${_TARGET_NAME}_int ALL
|
${_TARGET_NAME}_int ALL
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-DOUTPUT_PATH="${_SYMBOLS_OUTPUT_PATH}"
|
-DOUTPUT_PATH=${_SYMBOLS_OUTPUT_PATH}
|
||||||
-DHEADERS_LIST_FILE="${_HEADERS_LIST_FILE}"
|
-DHEADERS_LIST_FILE=${_HEADERS_LIST_FILE}
|
||||||
-DFILTER_PATTERN=${_extract_symbols_FILTER_PATTERN}
|
-DFILTER_PATTERN=${_extract_symbols_FILTER_PATTERN}
|
||||||
-P ${_EXTRACT_SYMBOLS_SCRIPT}
|
-P ${_EXTRACT_SYMBOLS_SCRIPT}
|
||||||
DEPENDS ${_extract_symbols_HEADERS_LIST}
|
DEPENDS ${_extract_symbols_HEADERS_LIST}
|
||||||
COMMENT "Extracting symbols from headers"
|
COMMENT "Extracting symbols from headers"
|
||||||
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
|
||||||
if (DEFINED _extract_symbols_COPY_TO)
|
if (DEFINED _extract_symbols_COPY_TO)
|
||||||
@@ -385,6 +388,7 @@ function(extract_symbols _TARGET_NAME)
|
|||||||
${_SYMBOLS_OUTPUT_PATH} ${_extract_symbols_COPY_TO}
|
${_SYMBOLS_OUTPUT_PATH} ${_extract_symbols_COPY_TO}
|
||||||
DEPENDS ${_TARGET_NAME}_int
|
DEPENDS ${_TARGET_NAME}_int
|
||||||
COMMENT "Copying ${_TARGET_NAME} to ${_extract_symbols_COPY_TO}"
|
COMMENT "Copying ${_TARGET_NAME} to ${_extract_symbols_COPY_TO}"
|
||||||
|
VERBATIM
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_custom_target(${_TARGET_NAME} ALL
|
add_custom_target(${_TARGET_NAME} ALL
|
||||||
@@ -449,35 +453,37 @@ function(generate_map_file _TARGET_NAME)
|
|||||||
${_TARGET_NAME}_int ALL
|
${_TARGET_NAME}_int ALL
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-DABIMAP_EXECUTABLE=${ABIMAP_EXECUTABLE}
|
-DABIMAP_EXECUTABLE=${ABIMAP_EXECUTABLE}
|
||||||
-DSYMBOLS="${_SYMBOLS_FILE}"
|
-DSYMBOLS=${_SYMBOLS_FILE}
|
||||||
-DCURRENT_MAP=${_generate_map_file_CURRENT_MAP}
|
-DCURRENT_MAP=${_generate_map_file_CURRENT_MAP}
|
||||||
-DOUTPUT_PATH="${_MAP_OUTPUT_PATH}"
|
-DOUTPUT_PATH=${_MAP_OUTPUT_PATH}
|
||||||
-DFINAL=${_generate_map_file_FINAL}
|
-DFINAL=${_generate_map_file_FINAL}
|
||||||
-DBREAK_ABI=${_generate_map_file_BREAK_ABI}
|
-DBREAK_ABI=${_generate_map_file_BREAK_ABI}
|
||||||
-DRELEASE_NAME_VERSION=${_generate_map_file_RELEASE_NAME_VERSION}
|
-DRELEASE_NAME_VERSION=${_generate_map_file_RELEASE_NAME_VERSION}
|
||||||
-P ${_GENERATE_MAP_SCRIPT}
|
-P ${_GENERATE_MAP_SCRIPT}
|
||||||
DEPENDS ${_generate_map_file_SYMBOLS}
|
DEPENDS ${_generate_map_file_SYMBOLS}
|
||||||
COMMENT "Generating the map ${_TARGET_NAME}"
|
COMMENT "Generating the map ${_TARGET_NAME}"
|
||||||
|
VERBATIM
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add a custom command setting the map as OUTPUT to allow it to be added as
|
# Add a custom command setting the map as OUTPUT to allow it to be added as
|
||||||
# a generated source
|
# a generated source
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${_MAP_OUTPUT_PATH}
|
OUTPUT ${_MAP_OUTPUT_PATH}
|
||||||
DEPENDS ${_TARGET_NAME}
|
DEPENDS ${_TARGET_NAME}_copy
|
||||||
)
|
)
|
||||||
|
|
||||||
if (DEFINED _generate_map_file_COPY_TO)
|
if (DEFINED _generate_map_file_COPY_TO)
|
||||||
# Copy the generated map back to the COPY_TO
|
# Copy the generated map back to the COPY_TO
|
||||||
add_custom_target(${_TARGET_NAME} ALL
|
add_custom_target(${_TARGET_NAME}_copy ALL
|
||||||
COMMAND
|
COMMAND
|
||||||
${CMAKE_COMMAND} -E copy_if_different ${_MAP_OUTPUT_PATH}
|
${CMAKE_COMMAND} -E copy_if_different ${_MAP_OUTPUT_PATH}
|
||||||
${_generate_map_file_COPY_TO}
|
${_generate_map_file_COPY_TO}
|
||||||
DEPENDS ${_TARGET_NAME}_int
|
DEPENDS ${_TARGET_NAME}_int
|
||||||
COMMENT "Copying ${_MAP_OUTPUT_PATH} to ${_generate_map_file_COPY_TO}"
|
COMMENT "Copying ${_MAP_OUTPUT_PATH} to ${_generate_map_file_COPY_TO}"
|
||||||
|
VERBATIM
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_custom_target(${_TARGET_NAME} ALL
|
add_custom_target(${_TARGET_NAME}_copy ALL
|
||||||
DEPENDS ${_TARGET_NAME}_int
|
DEPENDS ${_TARGET_NAME}_int
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
# - Try to find ARGP
|
# - Try to find ARGP
|
||||||
|
#
|
||||||
|
# The argp can be either shipped as part of libc (ex. glibc) or as a separate
|
||||||
|
# library that requires additional linking (ex. Windows, Mac, musl libc, ...)
|
||||||
|
#
|
||||||
# Once done this will define
|
# Once done this will define
|
||||||
#
|
#
|
||||||
# ARGP_ROOT_DIR - Set this variable to the root installation of ARGP
|
# ARGP_ROOT_DIR - Set this variable to the root installation of ARGP
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
|
# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
|
||||||
#
|
#
|
||||||
# Read-Only variables:
|
# Read-Only variables:
|
||||||
# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found
|
# GSSAPI_FLAVOR_MIT - set to TRUE if MIT Kerberos has been found
|
||||||
# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Keberos has been found
|
# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Keberos has been found
|
||||||
# GSSAPI_FOUND - system has GSSAPI
|
# GSSAPI_FOUND - system has GSSAPI
|
||||||
# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
|
# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
|
||||||
|
|||||||
36
cmake/Modules/Findsofthsm.cmake
Normal file
36
cmake/Modules/Findsofthsm.cmake
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# - Try to find softhsm
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# SOFTHSM_FOUND - system has softhsm
|
||||||
|
# SOFTHSM_LIBRARIES - Link these to use softhsm
|
||||||
|
#
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright (c) 2019 Sahana Prasad <sahana@redhat.com>
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
find_library(SOFTHSM2_LIBRARY
|
||||||
|
NAMES
|
||||||
|
softhsm2
|
||||||
|
)
|
||||||
|
|
||||||
|
if (SOFTHSM2_LIBRARY)
|
||||||
|
set(SOFTHSM_LIBRARIES
|
||||||
|
${SOFTHSM_LIBRARIES}
|
||||||
|
${SOFTHSM2_LIBRARY}
|
||||||
|
)
|
||||||
|
endif (SOFTHSM2_LIBRARY)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(softhsm DEFAULT_MSG SOFTHSM_LIBRARIES)
|
||||||
|
|
||||||
|
# show the SOFTHSM_INCLUDE_DIR and SOFTHSM_LIBRARIES variables only in the advanced view
|
||||||
|
mark_as_advanced(SOFTHSM_LIBRARIES)
|
||||||
@@ -82,13 +82,13 @@
|
|||||||
/* Define to 1 if you have the <pthread.h> header file. */
|
/* Define to 1 if you have the <pthread.h> header file. */
|
||||||
#cmakedefine HAVE_PTHREAD_H 1
|
#cmakedefine HAVE_PTHREAD_H 1
|
||||||
|
|
||||||
/* Define to 1 if you have eliptic curve cryptography in openssl */
|
/* Define to 1 if you have elliptic curve cryptography in openssl */
|
||||||
#cmakedefine HAVE_OPENSSL_ECC 1
|
#cmakedefine HAVE_OPENSSL_ECC 1
|
||||||
|
|
||||||
/* Define to 1 if you have eliptic curve cryptography in gcrypt */
|
/* Define to 1 if you have elliptic curve cryptography in gcrypt */
|
||||||
#cmakedefine HAVE_GCRYPT_ECC 1
|
#cmakedefine HAVE_GCRYPT_ECC 1
|
||||||
|
|
||||||
/* Define to 1 if you have eliptic curve cryptography */
|
/* Define to 1 if you have elliptic curve cryptography */
|
||||||
#cmakedefine HAVE_ECC 1
|
#cmakedefine HAVE_ECC 1
|
||||||
|
|
||||||
/* Define to 1 if you have DSA */
|
/* Define to 1 if you have DSA */
|
||||||
@@ -103,28 +103,19 @@
|
|||||||
/* Define to 1 if you have OpenSSL with X25519 support */
|
/* Define to 1 if you have OpenSSL with X25519 support */
|
||||||
#cmakedefine HAVE_OPENSSL_X25519 1
|
#cmakedefine HAVE_OPENSSL_X25519 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have OpenSSL with Poly1305 support */
|
||||||
|
#cmakedefine HAVE_OPENSSL_EVP_POLY1305 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have gcrypt with ChaCha20/Poly1305 support */
|
||||||
|
#cmakedefine HAVE_GCRYPT_CHACHA_POLY 1
|
||||||
|
|
||||||
/*************************** FUNCTIONS ***************************/
|
/*************************** FUNCTIONS ***************************/
|
||||||
|
|
||||||
/* Define to 1 if you have the `EVP_aes128_ctr' function. */
|
/* Define to 1 if you have the `EVP_chacha20' function. */
|
||||||
#cmakedefine HAVE_OPENSSL_EVP_AES_CTR 1
|
#cmakedefine HAVE_OPENSSL_EVP_CHACHA20 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `EVP_aes128_cbc' function. */
|
/* Define to 1 if you have the `EVP_KDF_CTX_new_id' or `EVP_KDF_CTX_new` function. */
|
||||||
#cmakedefine HAVE_OPENSSL_EVP_AES_CBC 1
|
#cmakedefine HAVE_OPENSSL_EVP_KDF_CTX 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `EVP_aes128_gcm' function. */
|
|
||||||
#cmakedefine HAVE_OPENSSL_EVP_AES_GCM 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `CRYPTO_THREADID_set_callback' function. */
|
|
||||||
#cmakedefine HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `CRYPTO_ctr128_encrypt' function. */
|
|
||||||
#cmakedefine HAVE_OPENSSL_CRYPTO_CTR128_ENCRYPT 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `EVP_CIPHER_CTX_new' function. */
|
|
||||||
#cmakedefine HAVE_OPENSSL_EVP_CIPHER_CTX_NEW 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `EVP_KDF_CTX_new_id' function. */
|
|
||||||
#cmakedefine HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `FIPS_mode' function. */
|
/* Define to 1 if you have the `FIPS_mode' function. */
|
||||||
#cmakedefine HAVE_OPENSSL_FIPS_MODE 1
|
#cmakedefine HAVE_OPENSSL_FIPS_MODE 1
|
||||||
@@ -234,6 +225,7 @@
|
|||||||
|
|
||||||
#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
|
#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
|
||||||
#cmakedefine HAVE_UNUSED_ATTRIBUTE 1
|
#cmakedefine HAVE_UNUSED_ATTRIBUTE 1
|
||||||
|
#cmakedefine HAVE_WEAK_ATTRIBUTE 1
|
||||||
|
|
||||||
#cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
|
#cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
|
||||||
#cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
|
#cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
|
||||||
@@ -260,6 +252,9 @@
|
|||||||
/* Define to 1 if you want to enable DH group exchange algorithms */
|
/* Define to 1 if you want to enable DH group exchange algorithms */
|
||||||
#cmakedefine WITH_GEX 1
|
#cmakedefine WITH_GEX 1
|
||||||
|
|
||||||
|
/* Define to 1 if you want to enable none cipher and MAC */
|
||||||
|
#cmakedefine WITH_INSECURE_NONE 1
|
||||||
|
|
||||||
/* Define to 1 if you want to enable blowfish cipher support */
|
/* Define to 1 if you want to enable blowfish cipher support */
|
||||||
#cmakedefine WITH_BLOWFISH_CIPHER 1
|
#cmakedefine WITH_BLOWFISH_CIPHER 1
|
||||||
|
|
||||||
@@ -278,6 +273,9 @@
|
|||||||
/* Define to 1 if you want to enable NaCl support */
|
/* Define to 1 if you want to enable NaCl support */
|
||||||
#cmakedefine WITH_NACL 1
|
#cmakedefine WITH_NACL 1
|
||||||
|
|
||||||
|
/* Define to 1 if you want to enable PKCS #11 URI support */
|
||||||
|
#cmakedefine WITH_PKCS11_URI 1
|
||||||
|
|
||||||
/*************************** ENDIAN *****************************/
|
/*************************** ENDIAN *****************************/
|
||||||
|
|
||||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||||
|
|||||||
@@ -13,9 +13,13 @@ if (DOXYGEN_FOUND)
|
|||||||
set(DOXYGEN_TAB_SIZE 4)
|
set(DOXYGEN_TAB_SIZE 4)
|
||||||
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
|
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
|
||||||
set(DOXYGEN_MARKDOWN_SUPPORT YES)
|
set(DOXYGEN_MARKDOWN_SUPPORT YES)
|
||||||
|
set(DOXYGEN_FULL_PATH_NAMES NO)
|
||||||
|
|
||||||
set(DOXYGEN_PREDEFINED DOXYGEN
|
set(DOXYGEN_PREDEFINED DOXYGEN
|
||||||
PRINTF_ATTRIBUTE(x,y))
|
WITH_SERVER
|
||||||
|
WITH_SFTP
|
||||||
|
PRINTF_ATTRIBUTE\(x,y\))
|
||||||
|
set(DOXYGEN_DOT_GRAPH_MAX_NODES 100)
|
||||||
|
|
||||||
set(DOXYGEN_EXCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/that_style)
|
set(DOXYGEN_EXCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/that_style)
|
||||||
set(DOXYGEN_HTML_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/that_style/header.html)
|
set(DOXYGEN_HTML_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/that_style/header.html)
|
||||||
|
|||||||
101
doc/README.gitlab.freebsd.md
Normal file
101
doc/README.gitlab.freebsd.md
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
# Install a FreeBSD CI instance
|
||||||
|
|
||||||
|
Install the following packages:
|
||||||
|
|
||||||
|
```
|
||||||
|
pkg install -y bash git gmake cmake cmocka openssl wget pkgconf ccache bash
|
||||||
|
```
|
||||||
|
|
||||||
|
Create gitlab-runner user:
|
||||||
|
|
||||||
|
```
|
||||||
|
pw group add -n gitlab-runner
|
||||||
|
pw user add -n gitlab-runner -g gitlab-runner -s /usr/local/bin/bash
|
||||||
|
mkdir /home/gitlab-runner
|
||||||
|
chown gitlab-runner:gitlab-runner /home/gitlab-runner
|
||||||
|
```
|
||||||
|
|
||||||
|
Get the gitlab-runner binary for freebsd:
|
||||||
|
|
||||||
|
```
|
||||||
|
wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-amd64
|
||||||
|
chmod +x /usr/local/bin/gitlab-runner
|
||||||
|
```
|
||||||
|
|
||||||
|
Create a log file and allow access:
|
||||||
|
|
||||||
|
```
|
||||||
|
touch /var/log/gitlab_runner.log && chown gitlab-runner:gitlab-runner /var/log/gitlab_runner.log
|
||||||
|
```
|
||||||
|
|
||||||
|
We need a start script to run it on boot:
|
||||||
|
|
||||||
|
```
|
||||||
|
mkdir -p /usr/local/etc/rc.d
|
||||||
|
cat > /usr/local/etc/rc.d/gitlab_runner << EOF
|
||||||
|
#!/usr/local/bin/bash
|
||||||
|
# PROVIDE: gitlab_runner
|
||||||
|
# REQUIRE: DAEMON NETWORKING
|
||||||
|
# BEFORE:
|
||||||
|
# KEYWORD:
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="gitlab_runner"
|
||||||
|
rcvar="gitlab_runner_enable"
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
|
||||||
|
user="gitlab-runner"
|
||||||
|
user_home="/home/gitlab-runner"
|
||||||
|
command="/usr/local/bin/gitlab-runner run"
|
||||||
|
pidfile="/var/run/${name}.pid"
|
||||||
|
|
||||||
|
start_cmd="gitlab_runner_start"
|
||||||
|
stop_cmd="gitlab_runner_stop"
|
||||||
|
status_cmd="gitlab_runner_status"
|
||||||
|
|
||||||
|
gitlab_runner_start()
|
||||||
|
{
|
||||||
|
export USER=${user}
|
||||||
|
export HOME=${user_home}
|
||||||
|
|
||||||
|
if checkyesno ${rcvar}; then
|
||||||
|
cd ${user_home}
|
||||||
|
/usr/sbin/daemon -u ${user} -p ${pidfile} ${command} > /var/log/gitlab_runner.log 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
gitlab_runner_stop()
|
||||||
|
{
|
||||||
|
if [ -f ${pidfile} ]; then
|
||||||
|
kill `cat ${pidfile}`
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
gitlab_runner_status()
|
||||||
|
{
|
||||||
|
if [ ! -f ${pidfile} ] || kill -0 `cat ${pidfile}`; then
|
||||||
|
echo "Service ${name} is not running."
|
||||||
|
else
|
||||||
|
echo "${name} appears to be running."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_rc_command $1
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/local/etc/rc.d/gitlab_runner
|
||||||
|
```
|
||||||
|
|
||||||
|
Register your gitlab-runner with your gitlab project
|
||||||
|
|
||||||
|
```
|
||||||
|
su gitlab-runner -c 'gitlab-runner register'
|
||||||
|
```
|
||||||
|
|
||||||
|
Start the gitlab runner service:
|
||||||
|
|
||||||
|
```
|
||||||
|
sysrc -f /etc/rc.conf "gitlab_runner_enable=YES"
|
||||||
|
service gitlab_runner start
|
||||||
|
```
|
||||||
@@ -33,6 +33,9 @@ The process of authenticating by public key to a server is the following:
|
|||||||
used to authenticate the user).
|
used to authenticate the user).
|
||||||
- then, you retrieve the private key for this key and send a message
|
- then, you retrieve the private key for this key and send a message
|
||||||
proving that you know that private key.
|
proving that you know that private key.
|
||||||
|
- when several identity files are specified, then the order of processing of
|
||||||
|
these files is from the last-mentioned to the first one
|
||||||
|
(if specified in the ~/.ssh/config, then starting from the bottom to the top).
|
||||||
|
|
||||||
The function ssh_userauth_autopubkey() does this using the available keys in
|
The function ssh_userauth_autopubkey() does this using the available keys in
|
||||||
"~/.ssh/". The return values are the following:
|
"~/.ssh/". The return values are the following:
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ curve25519-sha256@libssh.org.txt Aris Adamantiadis <aris@badcode.be>
|
|||||||
|
|
||||||
1. Introduction
|
1. Introduction
|
||||||
|
|
||||||
This document describes the key exchange methode curve25519-sha256@libssh.org
|
This document describes the key exchange method curve25519-sha256@libssh.org
|
||||||
for SSH version 2 protocol. It is provided as an alternative to the existing
|
for SSH version 2 protocol. It is provided as an alternative to the existing
|
||||||
key exchange mechanisms based on either Diffie-Hellman or Elliptic Curve Diffie-
|
key exchange mechanisms based on either Diffie-Hellman or Elliptic Curve Diffie-
|
||||||
Hellman [RFC5656].
|
Hellman [RFC5656].
|
||||||
The reason is the following : During summer of 2013, revelations from ex-
|
The reason is the following : During summer of 2013, revelations from ex-
|
||||||
consultant at NSA Edward Snowden gave proof that NSA willingly inserts backdoors
|
consultant at NSA Edward Snowden gave proof that NSA willingly inserts backdoors
|
||||||
into softwares, hardware components and published standards. While it is still
|
into software, hardware components and published standards. While it is still
|
||||||
believed that the mathematics behind ECC cryptography are still sound and solid,
|
believed that the mathematics behind ECC cryptography are still sound and solid,
|
||||||
some people (including Bruce Schneier [SCHNEIER]), showed their lack of confidence
|
some people (including Bruce Schneier [SCHNEIER]), showed their lack of confidence
|
||||||
in NIST-published curves such as nistp256, nistp384, nistp521, for which constant
|
in NIST-published curves such as nistp256, nistp384, nistp521, for which constant
|
||||||
@@ -42,8 +42,8 @@ The following is an overview of the key exchange process:
|
|||||||
Client Server
|
Client Server
|
||||||
------ ------
|
------ ------
|
||||||
Generate ephemeral key pair.
|
Generate ephemeral key pair.
|
||||||
SSH_MSG_KEX_ECDH_INIT -------->
|
SSH_MSG_KEX_ECDH_INIT -------->
|
||||||
Verify that client public key
|
Verify that client public key
|
||||||
length is 32 bytes.
|
length is 32 bytes.
|
||||||
Generate ephemeral key pair.
|
Generate ephemeral key pair.
|
||||||
Compute shared secret.
|
Compute shared secret.
|
||||||
@@ -55,7 +55,7 @@ Compute shared secret.
|
|||||||
Generate exchange hash.
|
Generate exchange hash.
|
||||||
Verify server's signature.
|
Verify server's signature.
|
||||||
|
|
||||||
* Optional but strongly recommanded as this protects against MITM attacks.
|
* Optional but strongly recommended as this protects against MITM attacks.
|
||||||
|
|
||||||
This is implemented using the same messages as described in RFC5656 chapter 4
|
This is implemented using the same messages as described in RFC5656 chapter 4
|
||||||
|
|
||||||
@@ -109,11 +109,11 @@ This number is calculated using the following procedure:
|
|||||||
side's public key and the local private key scalar.
|
side's public key and the local private key scalar.
|
||||||
|
|
||||||
The whole 32 bytes of the number X are then converted into a big integer k.
|
The whole 32 bytes of the number X are then converted into a big integer k.
|
||||||
This conversion follows the network byte order. This step differs from
|
This conversion follows the network byte order. This step differs from
|
||||||
RFC5656.
|
RFC5656.
|
||||||
|
|
||||||
[RFC5656] http://tools.ietf.org/html/rfc5656
|
[RFC5656] https://tools.ietf.org/html/rfc5656
|
||||||
[SCHNEIER] https://www.schneier.com/blog/archives/2013/09/the_nsa_is_brea.html#c1675929
|
[SCHNEIER] https://www.schneier.com/blog/archives/2013/09/the_nsa_is_brea.html#c1675929
|
||||||
[DJB] http://cr.yp.to/talks/2013.05.31/slides-dan+tanja-20130531-4x3.pdf
|
[DJB] https://cr.yp.to/talks/2013.05.31/slides-dan+tanja-20130531-4x3.pdf
|
||||||
[Curve25519] "Curve25519: new Diffie-Hellman speed records."
|
[Curve25519] "Curve25519: new Diffie-Hellman speed records."
|
||||||
http://cr.yp.to/ecdh/curve25519-20060209.pdf
|
https://cr.yp.to/ecdh/curve25519-20060209.pdf
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ used to retrieve google's home page from the remote SSH server.
|
|||||||
int direct_forwarding(ssh_session session)
|
int direct_forwarding(ssh_session session)
|
||||||
{
|
{
|
||||||
ssh_channel forwarding_channel;
|
ssh_channel forwarding_channel;
|
||||||
int rc;
|
int rc = SSH_ERROR;
|
||||||
char *http_get = "GET / HTTP/1.1\nHost: www.google.com\n\n";
|
char *http_get = "GET / HTTP/1.1\nHost: www.google.com\n\n";
|
||||||
int nbytes, nwritten;
|
int nbytes, nwritten;
|
||||||
|
|
||||||
@@ -165,6 +165,8 @@ int web_server(ssh_session session)
|
|||||||
char buffer[256];
|
char buffer[256];
|
||||||
int nbytes, nwritten;
|
int nbytes, nwritten;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
|
char *peer_address = NULL;
|
||||||
|
int peer_port = 0;
|
||||||
char *helloworld = ""
|
char *helloworld = ""
|
||||||
"HTTP/1.1 200 OK\n"
|
"HTTP/1.1 200 OK\n"
|
||||||
"Content-Type: text/html\n"
|
"Content-Type: text/html\n"
|
||||||
@@ -187,7 +189,8 @@ int web_server(ssh_session session)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = ssh_channel_accept_forward(session, 60000, &port);
|
channel = ssh_channel_open_forward_port(session, 60000, &port,
|
||||||
|
&peer_address, &peer_port);
|
||||||
if (channel == NULL)
|
if (channel == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error waiting for incoming connection: %s\n",
|
fprintf(stderr, "Error waiting for incoming connection: %s\n",
|
||||||
@@ -204,6 +207,7 @@ int web_server(ssh_session session)
|
|||||||
ssh_get_error(session));
|
ssh_get_error(session));
|
||||||
ssh_channel_send_eof(channel);
|
ssh_channel_send_eof(channel);
|
||||||
ssh_channel_free(channel);
|
ssh_channel_free(channel);
|
||||||
|
ssh_string_free_char(peer_address);
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
if (strncmp(buffer, "GET /", 5)) continue;
|
if (strncmp(buffer, "GET /", 5)) continue;
|
||||||
@@ -216,13 +220,15 @@ int web_server(ssh_session session)
|
|||||||
ssh_get_error(session));
|
ssh_get_error(session));
|
||||||
ssh_channel_send_eof(channel);
|
ssh_channel_send_eof(channel);
|
||||||
ssh_channel_free(channel);
|
ssh_channel_free(channel);
|
||||||
|
ssh_string_free_char(peer_address);
|
||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
printf("Sent answer\n");
|
printf("Sent answer to %s:%d\n", peer_address, peer_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_channel_send_eof(channel);
|
ssh_channel_send_eof(channel);
|
||||||
ssh_channel_free(channel);
|
ssh_channel_free(channel);
|
||||||
|
ssh_string_free_char(peer_address);
|
||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|||||||
@@ -28,6 +28,6 @@ the dllimport attribute.
|
|||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
If you're are statically linking with OpenSSL, read the "Linking your
|
If you're are statically linking with OpenSSL, read the "Linking your
|
||||||
application" section in the NOTES.<OS> in the OpenSSL source tree!
|
application" section in the NOTES.[OS] in the OpenSSL source tree!
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
100
doc/mainpage.dox
100
doc/mainpage.dox
@@ -21,9 +21,9 @@ The libssh library provides:
|
|||||||
|
|
||||||
- <strong>Key Exchange Methods</strong>: <i>curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521</i>, diffie-hellman-group1-sha1, diffie-hellman-group14-sha1
|
- <strong>Key Exchange Methods</strong>: <i>curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521</i>, diffie-hellman-group1-sha1, diffie-hellman-group14-sha1
|
||||||
- <strong>Public Key Algorithms</strong>: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-rsa, rsa-sha2-512, rsa-sha2-256,ssh-dss
|
- <strong>Public Key Algorithms</strong>: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-rsa, rsa-sha2-512, rsa-sha2-256,ssh-dss
|
||||||
- <strong>Ciphers</strong>: <i>aes256-ctr, aes192-ctr, aes128-ctr</i>, aes256-cbc (rijndael-cbc@lysator.liu.se), aes192-cbc, aes128-cbc, 3des-cbc, blowfish-cbc, none
|
- <strong>Ciphers</strong>: <i>aes256-ctr, aes192-ctr, aes128-ctr</i>, aes256-cbc (rijndael-cbc@lysator.liu.se), aes192-cbc, aes128-cbc, 3des-cbc, blowfish-cbc
|
||||||
- <strong>Compression Schemes</strong>: zlib, <i>zlib@openssh.com</i>, none
|
- <strong>Compression Schemes</strong>: zlib, <i>zlib@openssh.com</i>, none
|
||||||
- <strong>MAC hashes</strong>: hmac-sha1, hmac-sha2-256, hmac-sha2-512, hmac-md5, none
|
- <strong>MAC hashes</strong>: hmac-sha1, hmac-sha2-256, hmac-sha2-512, hmac-md5
|
||||||
- <strong>Authentication</strong>: none, password, public-key, keyboard-interactive, <i>gssapi-with-mic</i>
|
- <strong>Authentication</strong>: none, password, public-key, keyboard-interactive, <i>gssapi-with-mic</i>
|
||||||
- <strong>Channels</strong>: shell, exec (incl. SCP wrapper), direct-tcpip, subsystem, <i>auth-agent-req@openssh.com</i>
|
- <strong>Channels</strong>: shell, exec (incl. SCP wrapper), direct-tcpip, subsystem, <i>auth-agent-req@openssh.com</i>
|
||||||
- <strong>Global Requests</strong>: tcpip-forward, forwarded-tcpip
|
- <strong>Global Requests</strong>: tcpip-forward, forwarded-tcpip
|
||||||
@@ -38,9 +38,9 @@ The libssh library provides:
|
|||||||
@section main-additional-features Additional Features
|
@section main-additional-features Additional Features
|
||||||
|
|
||||||
- Client <b>and</b> server support
|
- Client <b>and</b> server support
|
||||||
- SSHv2 and SSHv1 protocol support
|
- SSHv2 protocol support
|
||||||
- Supports <a href="http://test.libssh.org/" target="_blank">Linux, UNIX, BSD, Solaris, OS/2 and Windows</a>
|
- Supports <a href="https://test.libssh.org/" target="_blank">Linux, UNIX, BSD, Solaris, OS/2 and Windows</a>
|
||||||
- Automated test cases with nightly <a href="http://test.libssh.org/" target="_blank">tests</a>
|
- Automated test cases with nightly <a href="https://test.libssh.org/" target="_blank">tests</a>
|
||||||
- Event model based on poll(2), or a poll(2)-emulation.
|
- Event model based on poll(2), or a poll(2)-emulation.
|
||||||
|
|
||||||
@section main-copyright Copyright Policy
|
@section main-copyright Copyright Policy
|
||||||
@@ -111,7 +111,7 @@ By making a contribution to this project, I certify that:
|
|||||||
Free Software Foundation; either version 2.1 of
|
Free Software Foundation; either version 2.1 of
|
||||||
the License, or (at the option of the project) any later version.
|
the License, or (at the option of the project) any later version.
|
||||||
|
|
||||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
https://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
@endverbatim
|
@endverbatim
|
||||||
|
|
||||||
We will maintain a copy of that email as a record that you have the rights to
|
We will maintain a copy of that email as a record that you have the rights to
|
||||||
@@ -149,49 +149,83 @@ The libssh Team
|
|||||||
|
|
||||||
@subsection main-rfc-secsh Secure Shell (SSH)
|
@subsection main-rfc-secsh Secure Shell (SSH)
|
||||||
|
|
||||||
The following RFC documents described SSH-2 protcol as an Internet standard.
|
The following RFC documents described SSH-2 protocol as an Internet standard.
|
||||||
|
|
||||||
- <a href="http://tools.ietf.org/html/rfc4250" target="_blank">RFC 4250</a>,
|
- <a href="https://tools.ietf.org/html/rfc4250" target="_blank">RFC 4250</a>,
|
||||||
The Secure Shell (SSH) Protocol Assigned Numbers
|
The Secure Shell (SSH) Protocol Assigned Numbers
|
||||||
- <a href="http://tools.ietf.org/html/rfc4251" target="_blank">RFC 4251</a>,
|
- <a href="https://tools.ietf.org/html/rfc4251" target="_blank">RFC 4251</a>,
|
||||||
The Secure Shell (SSH) Protocol Architecture
|
The Secure Shell (SSH) Protocol Architecture
|
||||||
- <a href="http://tools.ietf.org/html/rfc4252" target="_blank">RFC 4252</a>,
|
- <a href="https://tools.ietf.org/html/rfc4252" target="_blank">RFC 4252</a>,
|
||||||
The Secure Shell (SSH) Authentication Protocol
|
The Secure Shell (SSH) Authentication Protocol
|
||||||
- <a href="http://tools.ietf.org/html/rfc4253" target="_blank">RFC 4253</a>,
|
- <a href="https://tools.ietf.org/html/rfc4253" target="_blank">RFC 4253</a>,
|
||||||
The Secure Shell (SSH) Transport Layer Protocol
|
The Secure Shell (SSH) Transport Layer Protocol
|
||||||
- <a href="http://tools.ietf.org/html/rfc4254" target="_blank">RFC 4254</a>,
|
- <a href="https://tools.ietf.org/html/rfc4254" target="_blank">RFC 4254</a>,
|
||||||
The Secure Shell (SSH) Connection Protocol
|
The Secure Shell (SSH) Connection Protocol
|
||||||
- <a href="http://tools.ietf.org/html/rfc4255" target="_blank">RFC 4255</a>,
|
- <a href="https://tools.ietf.org/html/rfc4255" target="_blank">RFC 4255</a>,
|
||||||
Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
|
Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
|
||||||
- <a href="http://tools.ietf.org/html/rfc4256" target="_blank">RFC 4256</a>,
|
(not implemented in libssh)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc4256" target="_blank">RFC 4256</a>,
|
||||||
Generic Message Exchange Authentication for the Secure Shell Protocol (SSH)
|
Generic Message Exchange Authentication for the Secure Shell Protocol (SSH)
|
||||||
- <a href="http://tools.ietf.org/html/rfc4335" target="_blank">RFC 4335</a>,
|
- <a href="https://tools.ietf.org/html/rfc4335" target="_blank">RFC 4335</a>,
|
||||||
The Secure Shell (SSH) Session Channel Break Extension
|
The Secure Shell (SSH) Session Channel Break Extension
|
||||||
- <a href="http://tools.ietf.org/html/rfc4344" target="_blank">RFC 4344</a>,
|
- <a href="https://tools.ietf.org/html/rfc4344" target="_blank">RFC 4344</a>,
|
||||||
The Secure Shell (SSH) Transport Layer Encryption Modes
|
The Secure Shell (SSH) Transport Layer Encryption Modes
|
||||||
- <a href="http://tools.ietf.org/html/rfc4345" target="_blank">RFC 4345</a>,
|
- <a href="https://tools.ietf.org/html/rfc4345" target="_blank">RFC 4345</a>,
|
||||||
Improved Arcfour Modes for the Secure Shell (SSH) Transport Layer Protocol
|
Improved Arcfour Modes for the Secure Shell (SSH) Transport Layer Protocol
|
||||||
|
|
||||||
It was later modified and expanded by the following RFCs.
|
It was later modified and expanded by the following RFCs.
|
||||||
|
|
||||||
- <a href="http://tools.ietf.org/html/rfc4419" target="_blank">RFC 4419</a>,
|
- <a href="https://tools.ietf.org/html/rfc4419" target="_blank">RFC 4419</a>,
|
||||||
Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer
|
Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer
|
||||||
Protocol
|
Protocol
|
||||||
- <a href="http://tools.ietf.org/html/rfc4432" target="_blank">RFC 4432</a>,
|
- <a href="https://tools.ietf.org/html/rfc4432" target="_blank">RFC 4432</a>,
|
||||||
RSA Key Exchange for the Secure Shell (SSH) Transport Layer Protocol
|
RSA Key Exchange for the Secure Shell (SSH) Transport Layer Protocol
|
||||||
- <a href="http://tools.ietf.org/html/rfc4462" target="_blank">RFC 4462</a>,
|
(not implemented in libssh)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc4462" target="_blank">RFC 4462</a>,
|
||||||
Generic Security Service Application Program Interface (GSS-API)
|
Generic Security Service Application Program Interface (GSS-API)
|
||||||
Authentication and Key Exchange for the Secure Shell (SSH) Protocol
|
Authentication and Key Exchange for the Secure Shell (SSH) Protocol
|
||||||
- <a href="http://tools.ietf.org/html/rfc4716" target="_blank">RFC 4716</a>,
|
(only the authentication implemented in libssh)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc4716" target="_blank">RFC 4716</a>,
|
||||||
The Secure Shell (SSH) Public Key File Format
|
The Secure Shell (SSH) Public Key File Format
|
||||||
- <a href="http://tools.ietf.org/html/rfc5647" target="_blank">RFC 5647</a>,
|
(not implemented in libssh)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc5647" target="_blank">RFC 5647</a>,
|
||||||
AES Galois Counter Mode for the Secure Shell Transport Layer Protocol
|
AES Galois Counter Mode for the Secure Shell Transport Layer Protocol
|
||||||
- <a href="http://tools.ietf.org/html/rfc5656" target="_blank">RFC 5656</a>,
|
(the algorithm negotiation implemented according to openssh.com)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc5656" target="_blank">RFC 5656</a>,
|
||||||
Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer
|
Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc6594" target="_blank">RFC 6594</a>,
|
||||||
|
Use of the SHA-256 Algorithm with RSA, DSA, and ECDSA in SSHFP Resource Records
|
||||||
|
(not implemented in libssh)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc6668" target="_blank">RFC 6668</a>,
|
||||||
|
SHA-2 Data Integrity Verification for the Secure Shell (SSH) Transport Layer Protocol
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc7479" target="_blank">RFC 7479</a>,
|
||||||
|
Using Ed25519 in SSHFP Resource Records
|
||||||
|
(not implemented in libssh)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc8160" target="_blank">RFC 8160</a>,
|
||||||
|
IUTF8 Terminal Mode in Secure Shell (SSH)
|
||||||
|
(not handled in libssh)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc8270" target="_blank">RFC 8270</a>,
|
||||||
|
Increase the Secure Shell Minimum Recommended Diffie-Hellman Modulus Size to 2048 Bits
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc8308" target="_blank">RFC 8308</a>,
|
||||||
|
Extension Negotiation in the Secure Shell (SSH) Protocol
|
||||||
|
(only the "server-sig-algs" extension implemented)
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc8332" target="_blank">RFC 8332</a>,
|
||||||
|
Use of RSA Keys with SHA-256 and SHA-512 in the Secure Shell (SSH) Protocol
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc8709" target="_blank">RFC 8709</a>,
|
||||||
|
Ed25519 and Ed448 Public Key Algorithms for the Secure Shell (SSH) Protocol
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc8709" target="_blank">RFC 8731</a>,
|
||||||
|
Secure Shell (SSH) Key Exchange Method Using Curve25519 and Curve448
|
||||||
|
- <a href="https://tools.ietf.org/html/rfc9142" target="_blank">RFC 9142</a>,
|
||||||
|
Key Exchange (KEX) Method Updates and Recommendations for Secure Shell (SSH)
|
||||||
|
|
||||||
|
There are also drafts that are being currently developed and followed.
|
||||||
|
|
||||||
|
- <a href="https://tools.ietf.org/html/draft-miller-ssh-agent-03" target="_blank">draft-miller-ssh-agent-08</a>
|
||||||
|
SSH Agent Protocol
|
||||||
|
|
||||||
Interesting cryptography documents:
|
Interesting cryptography documents:
|
||||||
|
|
||||||
- <a href="http://www.cryptsoft.com/pkcs11doc/" target="_blank">PKCS #11</a>, PKCS #11 reference documents, describing interface with smartcards.
|
- <a href="https://www.cryptsoft.com/pkcs11doc/" target="_blank">PKCS #11</a>, PKCS #11 reference documents, describing interface with smartcards.
|
||||||
|
|
||||||
@subsection main-rfc-sftp Secure Shell File Transfer Protocol (SFTP)
|
@subsection main-rfc-sftp Secure Shell File Transfer Protocol (SFTP)
|
||||||
|
|
||||||
@@ -199,26 +233,22 @@ The protocol is not an Internet standard but it is still widely implemented.
|
|||||||
OpenSSH and most other implementation implement Version 3 of the protocol. We
|
OpenSSH and most other implementation implement Version 3 of the protocol. We
|
||||||
do the same in libssh.
|
do the same in libssh.
|
||||||
|
|
||||||
- <a href="http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02" target="_blank">
|
- <a href="https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02" target="_blank">
|
||||||
draft-ietf-secsh-filexfer-02.txt</a>,
|
draft-ietf-secsh-filexfer-02.txt</a>,
|
||||||
SSH File Transfer Protocol
|
SSH File Transfer Protocol
|
||||||
|
|
||||||
@subsection main-rfc-extensions Secure Shell Extensions
|
@subsection main-rfc-extensions Secure Shell Extensions
|
||||||
|
|
||||||
The libssh project has an extension to support Curve25519 which is also supported by
|
|
||||||
the OpenSSH project.
|
|
||||||
|
|
||||||
- <a href="http://git.libssh.org/projects/libssh.git/tree/doc/curve25519-sha256@libssh.org.txt" target="_blank">curve25519-sha256@libssh.org</a>,
|
|
||||||
Curve25519-SHA256 for ECDH KEX
|
|
||||||
|
|
||||||
The OpenSSH project has defined some extensions to the protocol. We support some of
|
The OpenSSH project has defined some extensions to the protocol. We support some of
|
||||||
them like the statvfs calls in SFTP or the ssh-agent.
|
them like the statvfs calls in SFTP or the ssh-agent.
|
||||||
|
|
||||||
- <a href="http://api.libssh.org/rfc/PROTOCOL" target="_blank">
|
- <a href="https://api.libssh.org/rfc/PROTOCOL" target="_blank">
|
||||||
OpenSSH's deviations and extensions</a>
|
OpenSSH's deviations and extensions</a>
|
||||||
- <a href="http://api.libssh.org/rfc/PROTOCOL.agent" target="_blank">
|
- <a href="https://api.libssh.org/rfc/PROTOCOL.certkeys" target="_blank">
|
||||||
OpenSSH's ssh-agent</a>
|
|
||||||
- <a href="http://api.libssh.org/rfc/PROTOCOL.certkeys" target="_blank">
|
|
||||||
OpenSSH's pubkey certificate authentication</a>
|
OpenSSH's pubkey certificate authentication</a>
|
||||||
|
- <a href="https://api.libssh.org/rfc/PROTOCOL.chacha20poly1305" target="_blank">
|
||||||
|
chacha20-poly1305@openssh.com authenticated encryption mode</a>
|
||||||
|
- <a href="https://api.libssh.org/rfc/PROTOCOL.key" target="_blank">
|
||||||
|
OpenSSH private key format (openssh-key-v1)</a>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
67
doc/pkcs11.dox
Normal file
67
doc/pkcs11.dox
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
@page libssh_tutor_pkcs11 Chapter 9: Authentication using PKCS #11 URIs
|
||||||
|
@section how_to How to use PKCS #11 URIs in libssh?
|
||||||
|
|
||||||
|
PKCS #11 is a Cryptographic Token Interface Standard that provides an API
|
||||||
|
to devices like smart cards that store cryptographic private information.
|
||||||
|
Such cryptographic devices are referenced as tokens. A mechanism through which
|
||||||
|
objects stored on the tokens can be uniquely identified is called PKCS #11 URI
|
||||||
|
(Uniform Resource Identifier) and is defined in RFC 7512
|
||||||
|
(https://tools.ietf.org/html/rfc7512).
|
||||||
|
|
||||||
|
Pre-requisites:
|
||||||
|
|
||||||
|
OpenSSL defines an abstract layer called the "engine" to achieve cryptographic
|
||||||
|
acceleration. The engine_pkcs11 module acts like an interface between the PKCS #11
|
||||||
|
modules and the OpenSSL engine.
|
||||||
|
|
||||||
|
To build and use libssh with PKCS #11 support:
|
||||||
|
1. Enable the cmake option: $ cmake -DWITH_PKCS11_URI=ON
|
||||||
|
2. Build with OpenSSL.
|
||||||
|
3. Install and configure engine_pkcs11 (https://github.com/OpenSC/libp11).
|
||||||
|
4. Plug in a working smart card or configure softhsm (https://www.opendnssec.org/softhsm).
|
||||||
|
|
||||||
|
The functions ssh_pki_import_pubkey_file() and ssh_pki_import_privkey_file() that
|
||||||
|
import the public and private keys from files respectively are now modified to support
|
||||||
|
PKCS #11 URIs. These functions automatically detect if the provided filename is a file path
|
||||||
|
or a PKCS #11 URI (when it begins with "pkcs11:"). If a PKCS #11 URI is detected,
|
||||||
|
the engine is loaded and initialized. Through the engine, the private/public key
|
||||||
|
corresponding to the PKCS #11 URI are loaded from the PKCS #11 device.
|
||||||
|
|
||||||
|
If you wish to authenticate using public keys on your own, follow the steps mentioned under
|
||||||
|
"Authentication with public keys" in Chapter 2 - A deeper insight into authentication.
|
||||||
|
|
||||||
|
The function pki_uri_import() is used to populate the public/private ssh_key from the
|
||||||
|
engine with PKCS #11 URIs as the look up.
|
||||||
|
|
||||||
|
Here is a minimalistic example of public key authentication using PKCS #11 URIs:
|
||||||
|
|
||||||
|
@code
|
||||||
|
int authenticate_pkcs11_URI(ssh_session session)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
char priv_uri[1042] = "pkcs11:token=my-token;object=my-object;type=private?pin-value=1234";
|
||||||
|
|
||||||
|
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, priv_uri);
|
||||||
|
assert_int_equal(rc, SSH_OK)
|
||||||
|
|
||||||
|
rc = ssh_userauth_publickey_auto(session, NULL, NULL);
|
||||||
|
|
||||||
|
if (rc == SSH_AUTH_ERROR)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Authentication with PKCS #11 URIs failed: %s\n",
|
||||||
|
ssh_get_error(session));
|
||||||
|
return SSH_AUTH_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
@subsection Caveats
|
||||||
|
|
||||||
|
We recommend the users to provide a specific PKCS #11 URI so that it matches only a single slot in the engine.
|
||||||
|
If the engine discovers multiple slots that could potentially contain the private keys referenced
|
||||||
|
by the provided PKCS #11 URI, the engine will not try to authenticate.
|
||||||
|
|
||||||
|
*/
|
||||||
@@ -320,18 +320,36 @@ int interactive_shell_session(ssh_session session, ssh_channel channel)
|
|||||||
If your remote application is graphical, you can forward the X11 protocol to
|
If your remote application is graphical, you can forward the X11 protocol to
|
||||||
your local computer.
|
your local computer.
|
||||||
|
|
||||||
To do that, you first declare that you accept X11 connections with
|
To do that, you first declare a callback to manage channel_open_request_x11_function.
|
||||||
ssh_channel_accept_x11(). Then you create the forwarding tunnel for
|
Then you create the forwarding tunnel for the X11 protocol with ssh_channel_request_x11().
|
||||||
the X11 protocol with ssh_channel_request_x11().
|
|
||||||
|
|
||||||
The following code performs channel initialization and shell session
|
The following code performs channel initialization and shell session
|
||||||
opening, and handles a parallel X11 connection:
|
opening, and handles a parallel X11 connection:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
#include <libssh/callbacks.h>
|
||||||
|
|
||||||
|
ssh_channel x11channel = NULL;
|
||||||
|
|
||||||
|
ssh_channel x11_open_request_callback(ssh_session session, const char *shost, int sport, void *userdata)
|
||||||
|
{
|
||||||
|
x11channel = ssh_channel_new(session);
|
||||||
|
return x11channel;
|
||||||
|
}
|
||||||
|
|
||||||
int interactive_shell_session(ssh_channel channel)
|
int interactive_shell_session(ssh_channel channel)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
ssh_channel x11channel;
|
|
||||||
|
struct ssh_callbacks_struct cb =
|
||||||
|
{
|
||||||
|
.channel_open_request_x11_function = x11_open_request_callback,
|
||||||
|
.userdata = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
ssh_callbacks_init(&cb);
|
||||||
|
rc = ssh_set_callbacks(session, &cb);
|
||||||
|
if (rc != SSH_OK) return rc;
|
||||||
|
|
||||||
rc = ssh_channel_request_pty(channel);
|
rc = ssh_channel_request_pty(channel);
|
||||||
if (rc != SSH_OK) return rc;
|
if (rc != SSH_OK) return rc;
|
||||||
@@ -350,12 +368,15 @@ int interactive_shell_session(ssh_channel channel)
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
Don't forget to set the $DISPLAY environment variable on the remote
|
Don't forget to check the $DISPLAY environment variable on the remote
|
||||||
side, or the remote applications won't try using the X11 tunnel:
|
side, or the remote applications won't try using the X11 tunnel:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
$ export DISPLAY=:0
|
$ echo $DISPLAY
|
||||||
|
localhost:10.0
|
||||||
$ xclock &
|
$ xclock &
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
See an implementation example at https://gitlab.com/libssh/libssh-mirror/-/tree/master/examples/ssh_X11_client.c for details.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ set(examples_SRCS
|
|||||||
connect_ssh.c
|
connect_ssh.c
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(${libssh_BINARY_DIR})
|
include_directories(${libssh_BINARY_DIR}/include ${libssh_BINARY_DIR})
|
||||||
|
|
||||||
if (ARGP_INCLUDE_DIR)
|
if (ARGP_INCLUDE_DIR)
|
||||||
include_directories(${ARGP_INCLUDE_DIR})
|
include_directories(${ARGP_INCLUDE_DIR})
|
||||||
@@ -35,34 +35,51 @@ if (UNIX AND NOT WIN32)
|
|||||||
target_compile_options(ssh-client PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
target_compile_options(ssh-client PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
target_link_libraries(ssh-client ssh::ssh)
|
target_link_libraries(ssh-client ssh::ssh)
|
||||||
|
|
||||||
if (WITH_SERVER AND (ARGP_LIBRARY OR HAVE_ARGP_H))
|
add_executable(ssh-X11-client ssh_X11_client.c ${examples_SRCS})
|
||||||
|
target_compile_options(ssh-X11-client PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
|
target_link_libraries(ssh-X11-client ssh::ssh)
|
||||||
|
|
||||||
|
if (WITH_SERVER AND (ARGP_LIBRARIES OR HAVE_ARGP_H))
|
||||||
if (HAVE_LIBUTIL)
|
if (HAVE_LIBUTIL)
|
||||||
add_executable(ssh_server_fork ssh_server_fork.c)
|
add_executable(ssh_server_fork ssh_server.c)
|
||||||
target_compile_options(ssh_server_fork PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
target_compile_options(ssh_server_fork PRIVATE ${DEFAULT_C_COMPILE_FLAGS} -DWITH_FORK)
|
||||||
target_link_libraries(ssh_server_fork ssh::ssh ${ARGP_LIBRARY} util)
|
target_link_libraries(ssh_server_fork ssh::ssh ${ARGP_LIBRARIES} util)
|
||||||
|
|
||||||
|
add_executable(ssh_server_pthread ssh_server.c)
|
||||||
|
target_compile_options(ssh_server_pthread PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
|
target_link_libraries(ssh_server_pthread ssh::ssh ${ARGP_LIBRARIES} pthread util)
|
||||||
endif (HAVE_LIBUTIL)
|
endif (HAVE_LIBUTIL)
|
||||||
|
|
||||||
if (WITH_GSSAPI AND GSSAPI_FOUND)
|
if (WITH_GSSAPI AND GSSAPI_FOUND)
|
||||||
add_executable(samplesshd-cb samplesshd-cb.c)
|
|
||||||
target_compile_options(samplesshd-cb PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
|
||||||
target_link_libraries(samplesshd-cb ssh::ssh ${ARGP_LIBRARY})
|
|
||||||
|
|
||||||
add_executable(proxy proxy.c)
|
add_executable(proxy proxy.c)
|
||||||
target_compile_options(proxy PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
target_compile_options(proxy PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
target_link_libraries(proxy ssh::ssh ${ARGP_LIBRARY})
|
target_link_libraries(proxy ssh::ssh ${ARGP_LIBRARIES})
|
||||||
|
|
||||||
add_executable(sshd_direct-tcpip sshd_direct-tcpip.c)
|
add_executable(sshd_direct-tcpip sshd_direct-tcpip.c)
|
||||||
target_compile_options(sshd_direct-tcpip PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
target_compile_options(sshd_direct-tcpip PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
target_link_libraries(sshd_direct-tcpip ssh::ssh ${ARGP_LIBRARY})
|
target_link_libraries(sshd_direct-tcpip ssh::ssh ${ARGP_LIBRARIES})
|
||||||
endif (WITH_GSSAPI AND GSSAPI_FOUND)
|
endif (WITH_GSSAPI AND GSSAPI_FOUND)
|
||||||
|
|
||||||
add_executable(samplesshd-kbdint samplesshd-kbdint.c)
|
add_executable(samplesshd-kbdint samplesshd-kbdint.c)
|
||||||
target_compile_options(samplesshd-kbdint PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
target_compile_options(samplesshd-kbdint PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
target_link_libraries(samplesshd-kbdint ssh::ssh ${ARGP_LIBRARY})
|
target_link_libraries(samplesshd-kbdint ssh::ssh ${ARGP_LIBRARIES})
|
||||||
|
|
||||||
|
add_executable(keygen2 keygen2.c ${examples_SRCS})
|
||||||
|
target_compile_options(keygen2 PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
|
target_link_libraries(keygen2 ssh::ssh ${ARGP_LIBRARIES})
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endif (UNIX AND NOT WIN32)
|
endif (UNIX AND NOT WIN32)
|
||||||
|
|
||||||
|
if (WITH_SERVER)
|
||||||
|
add_executable(samplesshd-cb samplesshd-cb.c)
|
||||||
|
target_compile_options(samplesshd-cb PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
|
target_link_libraries(samplesshd-cb ssh::ssh)
|
||||||
|
if (ARGP_LIBRARIES OR HAVE_ARGP_H)
|
||||||
|
target_link_libraries(samplesshd-cb ${ARGP_LIBRARIES})
|
||||||
|
endif(ARGP_LIBRARIES OR HAVE_ARGP_H)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(exec exec.c ${examples_SRCS})
|
add_executable(exec exec.c ${examples_SRCS})
|
||||||
target_compile_options(exec PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
target_compile_options(exec PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
|
||||||
target_link_libraries(exec ssh::ssh)
|
target_link_libraries(exec ssh::ssh)
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ int authenticate_console(ssh_session session)
|
|||||||
banner = ssh_get_issue_banner(session);
|
banner = ssh_get_issue_banner(session);
|
||||||
if (banner) {
|
if (banner) {
|
||||||
printf("%s\n",banner);
|
printf("%s\n",banner);
|
||||||
ssh_string_free_char(banner);
|
SSH_STRING_FREE_CHAR(banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ int main(void) {
|
|||||||
ssh_session session;
|
ssh_session session;
|
||||||
ssh_channel channel;
|
ssh_channel channel;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
int nbytes;
|
int rbytes, wbytes, total = 0;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
session = connect_ssh("localhost", NULL, 0);
|
session = connect_ssh("localhost", NULL, 0);
|
||||||
@@ -17,7 +17,7 @@ int main(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = ssh_channel_new(session);;
|
channel = ssh_channel_new(session);
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
ssh_free(session);
|
ssh_free(session);
|
||||||
@@ -35,15 +35,30 @@ int main(void) {
|
|||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
|
rbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
|
||||||
while (nbytes > 0) {
|
if (rbytes <= 0) {
|
||||||
if (fwrite(buffer, 1, nbytes, stdout) != (unsigned int) nbytes) {
|
goto failed;
|
||||||
goto failed;
|
|
||||||
}
|
|
||||||
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbytes < 0) {
|
do {
|
||||||
|
wbytes = fwrite(buffer + total, 1, rbytes, stdout);
|
||||||
|
if (wbytes <= 0) {
|
||||||
|
goto failed;
|
||||||
|
}
|
||||||
|
|
||||||
|
total += wbytes;
|
||||||
|
|
||||||
|
/* When it was not possible to write the whole buffer to stdout */
|
||||||
|
if (wbytes < rbytes) {
|
||||||
|
rbytes -= wbytes;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
|
||||||
|
total = 0;
|
||||||
|
} while (rbytes > 0);
|
||||||
|
|
||||||
|
if (rbytes < 0) {
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
505
examples/keygen2.c
Normal file
505
examples/keygen2.c
Normal file
@@ -0,0 +1,505 @@
|
|||||||
|
/*
|
||||||
|
* keygen2.c - Generate SSH keys using libssh
|
||||||
|
* Author: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <libssh/libssh.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <argp.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
struct arguments_st {
|
||||||
|
enum ssh_keytypes_e type;
|
||||||
|
unsigned long bits;
|
||||||
|
char *file;
|
||||||
|
char *passphrase;
|
||||||
|
int action_list;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct argp_option options[] = {
|
||||||
|
{
|
||||||
|
.name = "bits",
|
||||||
|
.key = 'b',
|
||||||
|
.arg = "BITS",
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "The size of the key to be generated. "
|
||||||
|
"If omitted, a default value is used depending on the TYPE. "
|
||||||
|
"Accepted values are: "
|
||||||
|
"1024, 2048, 3072 (default), 4096, and 8192 for TYPE=\"rsa\"; "
|
||||||
|
"256 (default), 384, and 521 for TYPE=\"ecdsa\"; "
|
||||||
|
"1024 (default) and 2048 for TYPE=\"dsa\"; "
|
||||||
|
"can be omitted for TYPE=\"ed25519\" "
|
||||||
|
"(it will be ignored if provided).\n",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "file",
|
||||||
|
.key = 'f',
|
||||||
|
.arg = "FILE",
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "The output file. "
|
||||||
|
"If not provided, the used file name will be generated "
|
||||||
|
"according to the key type as \"id_TYPE\" "
|
||||||
|
"(e.g. \"id_rsa\" for type \"rsa\"). "
|
||||||
|
"The public key file name is generated from the private key "
|
||||||
|
"file name by appending \".pub\".\n",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "passphrase",
|
||||||
|
.key = 'p',
|
||||||
|
.arg = "PASSPHRASE",
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "The passphrase used to encrypt the private key. "
|
||||||
|
"If omitted the file will not be encrypted.\n",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "type",
|
||||||
|
.key = 't',
|
||||||
|
.arg = "TYPE",
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "The type of the key to be generated. "
|
||||||
|
"Accepted values are: "
|
||||||
|
"\"rsa\", \"ecdsa\", \"ed25519\", and \"dsa\".\n",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "list",
|
||||||
|
.key = 'l',
|
||||||
|
.arg = NULL,
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "List the Fingerprint of the given key\n",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
/* End of the options */
|
||||||
|
0
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Parse a single option. */
|
||||||
|
static error_t parse_opt (int key, char *arg, struct argp_state *state)
|
||||||
|
{
|
||||||
|
/* Get the input argument from argp_parse, which we
|
||||||
|
* know is a pointer to our arguments structure.
|
||||||
|
*/
|
||||||
|
struct arguments_st *arguments = NULL;
|
||||||
|
error_t rc = 0;
|
||||||
|
|
||||||
|
if (state == NULL) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
arguments = state->input;
|
||||||
|
if (arguments == NULL) {
|
||||||
|
fprintf(stderr, "Error: NULL pointer to arguments structure "
|
||||||
|
"provided\n");
|
||||||
|
rc = EINVAL;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 'b':
|
||||||
|
errno = 0;
|
||||||
|
arguments->bits = strtoul(arg, NULL, 10);
|
||||||
|
if (errno != 0) {
|
||||||
|
rc = errno;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
arguments->file = strdup(arg);
|
||||||
|
if (arguments->file == NULL) {
|
||||||
|
fprintf(stderr, "Error: Out of memory\n");
|
||||||
|
rc = ENOMEM;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
arguments->passphrase = strdup(arg);
|
||||||
|
if (arguments->passphrase == NULL) {
|
||||||
|
fprintf(stderr, "Error: Out of memory\n");
|
||||||
|
rc = ENOMEM;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
if (!strcmp(arg, "rsa")) {
|
||||||
|
arguments->type = SSH_KEYTYPE_RSA;
|
||||||
|
}
|
||||||
|
else if (!strcmp(arg, "dsa")) {
|
||||||
|
arguments->type = SSH_KEYTYPE_DSS;
|
||||||
|
}
|
||||||
|
else if (!strcmp(arg, "ecdsa")) {
|
||||||
|
arguments->type = SSH_KEYTYPE_ECDSA;
|
||||||
|
}
|
||||||
|
else if (!strcmp(arg, "ed25519")) {
|
||||||
|
arguments->type = SSH_KEYTYPE_ED25519;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "Error: Invalid key type\n");
|
||||||
|
argp_usage(state);
|
||||||
|
rc = EINVAL;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
arguments->action_list = 1;
|
||||||
|
break;
|
||||||
|
case ARGP_KEY_ARG:
|
||||||
|
if (state->arg_num > 0) {
|
||||||
|
/* Too many arguments. */
|
||||||
|
printf("Error: Too many arguments\n");
|
||||||
|
argp_usage(state);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ARGP_KEY_END:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return ARGP_ERR_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int validate_args(struct arguments_st *args)
|
||||||
|
{
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
|
if (args == NULL) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* no other arguments needed for listing key fingerprints */
|
||||||
|
if (args->action_list) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args->type) {
|
||||||
|
case SSH_KEYTYPE_RSA:
|
||||||
|
switch (args->bits) {
|
||||||
|
case 0:
|
||||||
|
/* If not provided, use default value */
|
||||||
|
args->bits = 3072;
|
||||||
|
break;
|
||||||
|
case 1024:
|
||||||
|
case 2048:
|
||||||
|
case 3072:
|
||||||
|
case 4096:
|
||||||
|
case 8192:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Error: Invalid bits parameter provided\n");
|
||||||
|
rc = EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args->file == NULL) {
|
||||||
|
args->file = strdup("id_rsa");
|
||||||
|
if (args->file == NULL) {
|
||||||
|
rc = ENOMEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SSH_KEYTYPE_ECDSA:
|
||||||
|
switch (args->bits) {
|
||||||
|
case 0:
|
||||||
|
/* If not provided, use default value */
|
||||||
|
args->bits = 256;
|
||||||
|
break;
|
||||||
|
case 256:
|
||||||
|
case 384:
|
||||||
|
case 521:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Error: Invalid bits parameter provided\n");
|
||||||
|
rc = EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (args->file == NULL) {
|
||||||
|
args->file = strdup("id_ecdsa");
|
||||||
|
if (args->file == NULL) {
|
||||||
|
rc = ENOMEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SSH_KEYTYPE_DSS:
|
||||||
|
switch (args->bits) {
|
||||||
|
case 0:
|
||||||
|
/* If not provided, use default value */
|
||||||
|
args->bits = 1024;
|
||||||
|
break;
|
||||||
|
case 1024:
|
||||||
|
case 2048:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Error: Invalid bits parameter provided\n");
|
||||||
|
rc = EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (args->file == NULL) {
|
||||||
|
args->file = strdup("id_dsa");
|
||||||
|
if (args->file == NULL) {
|
||||||
|
rc = ENOMEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SSH_KEYTYPE_ED25519:
|
||||||
|
/* Ignore value and overwrite with a zero */
|
||||||
|
args->bits = 0;
|
||||||
|
|
||||||
|
if (args->file == NULL) {
|
||||||
|
args->file = strdup("id_ed25519");
|
||||||
|
if (args->file == NULL) {
|
||||||
|
rc = ENOMEM;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Error: unknown key type\n");
|
||||||
|
rc = EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Program documentation. */
|
||||||
|
static char doc[] = "Generate an SSH key pair. "
|
||||||
|
"The \"--type\" (short: \"-t\") option is required.";
|
||||||
|
|
||||||
|
/* Our argp parser */
|
||||||
|
static struct argp argp = {options, parse_opt, NULL, doc, NULL, NULL, NULL};
|
||||||
|
|
||||||
|
static void
|
||||||
|
list_fingerprint(char *file)
|
||||||
|
{
|
||||||
|
ssh_key key = NULL;
|
||||||
|
unsigned char *hash = NULL;
|
||||||
|
size_t hlen = 0;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = ssh_pki_import_privkey_file(file, NULL, NULL, NULL, &key);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
fprintf(stderr, "Failed to import private key %s\n", file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = ssh_get_publickey_hash(key, SSH_PUBLICKEY_HASH_SHA256, &hash, &hlen);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
fprintf(stderr, "Failed to get key fingerprint\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ssh_print_hash(SSH_PUBLICKEY_HASH_SHA256, hash, hlen);
|
||||||
|
|
||||||
|
ssh_clean_pubkey_hash(&hash);
|
||||||
|
ssh_key_free(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
ssh_key key = NULL;
|
||||||
|
int rc = 0;
|
||||||
|
char overwrite[1024] = "";
|
||||||
|
|
||||||
|
char *pubkey_file = NULL;
|
||||||
|
|
||||||
|
struct arguments_st arguments = {
|
||||||
|
.type = SSH_KEYTYPE_UNKNOWN,
|
||||||
|
.bits = 0,
|
||||||
|
.file = NULL,
|
||||||
|
.passphrase = NULL,
|
||||||
|
.action_list = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
argp_help(&argp, stdout, ARGP_HELP_DOC | ARGP_HELP_USAGE, argv[0]);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||||
|
if (rc != 0) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = validate_args(&arguments);
|
||||||
|
if (rc != 0) {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments.action_list && arguments.file) {
|
||||||
|
list_fingerprint(arguments.file);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
rc = open(arguments.file, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
|
||||||
|
if (rc < 0) {
|
||||||
|
if (errno == EEXIST) {
|
||||||
|
printf("File \"%s\" exists. Overwrite it? (y|n) ", arguments.file);
|
||||||
|
rc = scanf("%1023s", overwrite);
|
||||||
|
if (rc > 0 && tolower(overwrite[0]) == 'y') {
|
||||||
|
rc = open(arguments.file, O_WRONLY);
|
||||||
|
if (rc > 0) {
|
||||||
|
close(rc);
|
||||||
|
errno = 0;
|
||||||
|
rc = chmod(arguments.file, S_IRUSR | S_IWUSR);
|
||||||
|
if (rc != 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Error(%d): Could not set file permissions\n",
|
||||||
|
errno);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Error: Could not create private key file\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error opening \"%s\" file\n", arguments.file);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
close(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Generate a new private key */
|
||||||
|
rc = ssh_pki_generate(arguments.type, arguments.bits, &key);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
fprintf(stderr, "Error: Failed to generate keys");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write the private key */
|
||||||
|
rc = ssh_pki_export_privkey_file(key, arguments.passphrase, NULL, NULL,
|
||||||
|
arguments.file);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
fprintf(stderr, "Error: Failed to write private key file");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If a passphrase was provided, overwrite and free it as it is not needed
|
||||||
|
* anymore */
|
||||||
|
if (arguments.passphrase != NULL) {
|
||||||
|
#ifdef HAVE_EXPLICIT_BZERO
|
||||||
|
explicit_bzero(arguments.passphrase, strlen(arguments.passphrase));
|
||||||
|
#else
|
||||||
|
bzero(arguments.passphrase, strlen(arguments.passphrase));
|
||||||
|
#endif
|
||||||
|
free(arguments.passphrase);
|
||||||
|
arguments.passphrase = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pubkey_file = (char *)malloc(strlen(arguments.file) + 5);
|
||||||
|
if (pubkey_file == NULL) {
|
||||||
|
rc = ENOMEM;
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(pubkey_file, "%s.pub", arguments.file);
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
rc = open(pubkey_file,
|
||||||
|
O_CREAT | O_EXCL | O_WRONLY,
|
||||||
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||||
|
if (rc < 0) {
|
||||||
|
if (errno == EEXIST) {
|
||||||
|
printf("File \"%s\" exists. Overwrite it? (y|n) ", pubkey_file);
|
||||||
|
rc = scanf("%1023s", overwrite);
|
||||||
|
if (rc > 0 && tolower(overwrite[0]) == 'y') {
|
||||||
|
rc = open(pubkey_file, O_WRONLY);
|
||||||
|
if (rc > 0) {
|
||||||
|
close(rc);
|
||||||
|
errno = 0;
|
||||||
|
rc = chmod(pubkey_file,
|
||||||
|
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||||
|
if (rc != 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Error(%d): Could not set file permissions\n",
|
||||||
|
errno);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Error: Could not create public key file\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error opening \"%s\" file\n", pubkey_file);
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
close(rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write the public key */
|
||||||
|
rc = ssh_pki_export_pubkey_file(key, pubkey_file);
|
||||||
|
if (rc != SSH_OK) {
|
||||||
|
fprintf(stderr, "Error: Failed to write public key file");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (key != NULL) {
|
||||||
|
ssh_key_free(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments.file != NULL) {
|
||||||
|
free(arguments.file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments.passphrase != NULL) {
|
||||||
|
#ifdef HAVE_EXPLICIT_BZERO
|
||||||
|
explicit_bzero(arguments.passphrase, strlen(arguments.passphrase));
|
||||||
|
#else
|
||||||
|
bzero(arguments.passphrase, strlen(arguments.passphrase));
|
||||||
|
#endif
|
||||||
|
free(arguments.passphrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pubkey_file != NULL) {
|
||||||
|
free(pubkey_file);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
@@ -22,6 +22,10 @@ program.
|
|||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
#include "examples_common.h"
|
#include "examples_common.h"
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 16384
|
||||||
|
#endif
|
||||||
|
|
||||||
static char **sources;
|
static char **sources;
|
||||||
static int nsources;
|
static int nsources;
|
||||||
static char *destination;
|
static char *destination;
|
||||||
@@ -105,10 +109,6 @@ static void location_free(struct location *loc)
|
|||||||
free(loc->user);
|
free(loc->user);
|
||||||
}
|
}
|
||||||
loc->user = NULL;
|
loc->user = NULL;
|
||||||
if (loc->host) {
|
|
||||||
free(loc->host);
|
|
||||||
}
|
|
||||||
loc->host = NULL;
|
|
||||||
}
|
}
|
||||||
free(loc);
|
free(loc);
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ static int open_location(struct location *loc, int flag) {
|
|||||||
loc->file = fopen(loc->path, flag == READ ? "r":"w");
|
loc->file = fopen(loc->path, flag == READ ? "r":"w");
|
||||||
if (!loc->file) {
|
if (!loc->file) {
|
||||||
if (errno == EISDIR) {
|
if (errno == EISDIR) {
|
||||||
if (chdir(loc->path)) {
|
if (loc->path != NULL && chdir(loc->path)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error changing directory to %s: %s\n",
|
"Error changing directory to %s: %s\n",
|
||||||
loc->path, strerror(errno));
|
loc->path, strerror(errno));
|
||||||
@@ -257,14 +257,15 @@ static int open_location(struct location *loc, int flag) {
|
|||||||
* @param recursive Copy also directories
|
* @param recursive Copy also directories
|
||||||
*/
|
*/
|
||||||
static int do_copy(struct location *src, struct location *dest, int recursive) {
|
static int do_copy(struct location *src, struct location *dest, int recursive) {
|
||||||
int size;
|
size_t size;
|
||||||
socket_t fd;
|
socket_t fd;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
int w, r;
|
int w, r;
|
||||||
char buffer[16384];
|
char buffer[BUF_SIZE];
|
||||||
int total = 0;
|
size_t total = 0;
|
||||||
int mode;
|
mode_t mode;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
|
|
||||||
/* recursive mode doesn't work yet */
|
/* recursive mode doesn't work yet */
|
||||||
(void)recursive;
|
(void)recursive;
|
||||||
/* Get the file name and size*/
|
/* Get the file name and size*/
|
||||||
@@ -302,7 +303,7 @@ static int do_copy(struct location *src, struct location *dest, int recursive) {
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error: %s\n",
|
"Error: %s\n",
|
||||||
ssh_get_error(src->session));
|
ssh_get_error(src->session));
|
||||||
ssh_string_free_char(filename);
|
SSH_STRING_FREE_CHAR(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} while(r != SSH_SCP_REQUEST_NEWFILE);
|
} while(r != SSH_SCP_REQUEST_NEWFILE);
|
||||||
@@ -315,7 +316,7 @@ static int do_copy(struct location *src, struct location *dest, int recursive) {
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"error: %s\n",
|
"error: %s\n",
|
||||||
ssh_get_error(dest->session));
|
ssh_get_error(dest->session));
|
||||||
ssh_string_free_char(filename);
|
SSH_STRING_FREE_CHAR(filename);
|
||||||
ssh_scp_free(dest->scp);
|
ssh_scp_free(dest->scp);
|
||||||
dest->scp = NULL;
|
dest->scp = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
@@ -330,7 +331,7 @@ static int do_copy(struct location *src, struct location *dest, int recursive) {
|
|||||||
if (src->is_ssh) {
|
if (src->is_ssh) {
|
||||||
ssh_scp_deny_request(src->scp, "Cannot open local file");
|
ssh_scp_deny_request(src->scp, "Cannot open local file");
|
||||||
}
|
}
|
||||||
ssh_string_free_char(filename);
|
SSH_STRING_FREE_CHAR(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -346,7 +347,7 @@ static int do_copy(struct location *src, struct location *dest, int recursive) {
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error reading scp: %s\n",
|
"Error reading scp: %s\n",
|
||||||
ssh_get_error(src->session));
|
ssh_get_error(src->session));
|
||||||
ssh_string_free_char(filename);
|
SSH_STRING_FREE_CHAR(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +364,7 @@ static int do_copy(struct location *src, struct location *dest, int recursive) {
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error reading file: %s\n",
|
"Error reading file: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
ssh_string_free_char(filename);
|
SSH_STRING_FREE_CHAR(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,7 +377,7 @@ static int do_copy(struct location *src, struct location *dest, int recursive) {
|
|||||||
ssh_get_error(dest->session));
|
ssh_get_error(dest->session));
|
||||||
ssh_scp_free(dest->scp);
|
ssh_scp_free(dest->scp);
|
||||||
dest->scp = NULL;
|
dest->scp = NULL;
|
||||||
ssh_string_free_char(filename);
|
SSH_STRING_FREE_CHAR(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -385,7 +386,7 @@ static int do_copy(struct location *src, struct location *dest, int recursive) {
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error writing in local file: %s\n",
|
"Error writing in local file: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
ssh_string_free_char(filename);
|
SSH_STRING_FREE_CHAR(filename);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,8 +394,8 @@ static int do_copy(struct location *src, struct location *dest, int recursive) {
|
|||||||
|
|
||||||
} while(total < size);
|
} while(total < size);
|
||||||
|
|
||||||
ssh_string_free_char(filename);
|
SSH_STRING_FREE_CHAR(filename);
|
||||||
printf("wrote %d bytes\n", total);
|
printf("wrote %zu bytes\n", total);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,10 +404,11 @@ int main(int argc, char **argv) {
|
|||||||
int i;
|
int i;
|
||||||
int r;
|
int r;
|
||||||
if (opts(argc, argv) < 0) {
|
if (opts(argc, argv) < 0) {
|
||||||
r = EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssh_init();
|
||||||
|
|
||||||
dest = parse_location(destination);
|
dest = parse_location(destination);
|
||||||
if (dest == NULL) {
|
if (dest == NULL) {
|
||||||
r = EXIT_FAILURE;
|
r = EXIT_FAILURE;
|
||||||
@@ -448,5 +450,7 @@ close_dest:
|
|||||||
close_location(dest);
|
close_location(dest);
|
||||||
location_free(dest);
|
location_free(dest);
|
||||||
end:
|
end:
|
||||||
|
ssh_finalize();
|
||||||
|
free(sources);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ clients must be made or how a client should react.
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 2048
|
||||||
|
#endif
|
||||||
|
|
||||||
#define USER "myuser"
|
#define USER "myuser"
|
||||||
#define PASSWORD "mypassword"
|
#define PASSWORD "mypassword"
|
||||||
|
|
||||||
@@ -225,7 +229,7 @@ int main(int argc, char **argv){
|
|||||||
.channel_open_request_session_function = new_session_channel
|
.channel_open_request_session_function = new_session_channel
|
||||||
};
|
};
|
||||||
|
|
||||||
char buf[2048];
|
char buf[BUF_SIZE];
|
||||||
char host[128]="";
|
char host[128]="";
|
||||||
char *ptr;
|
char *ptr;
|
||||||
int i,r, rc;
|
int i,r, rc;
|
||||||
@@ -291,7 +295,7 @@ int main(int argc, char **argv){
|
|||||||
snprintf(buf,sizeof(buf), "Hello %s, welcome to the Sample SSH proxy.\r\nPlease select your destination: ", username);
|
snprintf(buf,sizeof(buf), "Hello %s, welcome to the Sample SSH proxy.\r\nPlease select your destination: ", username);
|
||||||
ssh_channel_write(chan, buf, strlen(buf));
|
ssh_channel_write(chan, buf, strlen(buf));
|
||||||
do{
|
do{
|
||||||
i=ssh_channel_read(chan,buf, 2048, 0);
|
i=ssh_channel_read(chan,buf, sizeof(buf), 0);
|
||||||
if(i>0) {
|
if(i>0) {
|
||||||
ssh_channel_write(chan, buf, i);
|
ssh_channel_write(chan, buf, i);
|
||||||
if(strlen(host) + i < sizeof(host)){
|
if(strlen(host) + i < sizeof(host)){
|
||||||
|
|||||||
@@ -29,11 +29,13 @@ clients must be made or how a client should react.
|
|||||||
#include "examples_common.h"
|
#include "examples_common.h"
|
||||||
#ifdef WITH_SFTP
|
#ifdef WITH_SFTP
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 65536
|
||||||
|
#endif
|
||||||
|
|
||||||
static int verbosity;
|
static int verbosity;
|
||||||
static char *destination;
|
static char *destination;
|
||||||
|
|
||||||
#define DATALEN 65536
|
|
||||||
|
|
||||||
static void do_sftp(ssh_session session) {
|
static void do_sftp(ssh_session session) {
|
||||||
sftp_session sftp = sftp_new(session);
|
sftp_session sftp = sftp_new(session);
|
||||||
sftp_dir dir;
|
sftp_dir dir;
|
||||||
@@ -44,8 +46,8 @@ static void do_sftp(ssh_session session) {
|
|||||||
sftp_file to;
|
sftp_file to;
|
||||||
int len = 1;
|
int len = 1;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char data[DATALEN] = {0};
|
char data[BUF_SIZE] = {0};
|
||||||
char *lnk;
|
char *lnk = NULL;
|
||||||
|
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
@@ -84,6 +86,7 @@ static void do_sftp(ssh_session session) {
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
printf("readlink /tmp/sftp_symlink_test: %s\n", lnk);
|
printf("readlink /tmp/sftp_symlink_test: %s\n", lnk);
|
||||||
|
ssh_string_free_char(lnk);
|
||||||
|
|
||||||
sftp_unlink(sftp, "/tmp/sftp_symlink_test");
|
sftp_unlink(sftp, "/tmp/sftp_symlink_test");
|
||||||
|
|
||||||
@@ -171,7 +174,7 @@ static void do_sftp(ssh_session session) {
|
|||||||
sftp_attributes_free(file);
|
sftp_attributes_free(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* when file = NULL, an error has occured OR the directory listing is end of
|
/* when file = NULL, an error has occurred OR the directory listing is end of
|
||||||
* file */
|
* file */
|
||||||
if (!sftp_dir_eof(dir)) {
|
if (!sftp_dir_eof(dir)) {
|
||||||
fprintf(stderr, "Error: %s\n", ssh_get_error(session));
|
fprintf(stderr, "Error: %s\n", ssh_get_error(session));
|
||||||
@@ -223,9 +226,9 @@ static void do_sftp(ssh_session session) {
|
|||||||
to = sftp_open(sftp, "/tmp/grosfichier", O_WRONLY|O_CREAT, 0644);
|
to = sftp_open(sftp, "/tmp/grosfichier", O_WRONLY|O_CREAT, 0644);
|
||||||
|
|
||||||
for (i = 0; i < 1000; ++i) {
|
for (i = 0; i < 1000; ++i) {
|
||||||
len = sftp_write(to, data, DATALEN);
|
len = sftp_write(to, data, sizeof(data));
|
||||||
printf("wrote %d bytes\n", len);
|
printf("wrote %d bytes\n", len);
|
||||||
if (len != DATALEN) {
|
if (len != sizeof(data)) {
|
||||||
printf("chunk %d : %d (%s)\n", i, len, ssh_get_error(session));
|
printf("chunk %d : %d (%s)\n", i, len, ssh_get_error(session));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ clients must be made or how a client should react.
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 2049
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef KEYS_FOLDER
|
#ifndef KEYS_FOLDER
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define KEYS_FOLDER
|
#define KEYS_FOLDER
|
||||||
@@ -41,6 +49,27 @@ static int tries = 0;
|
|||||||
static int error = 0;
|
static int error = 0;
|
||||||
static ssh_channel chan=NULL;
|
static ssh_channel chan=NULL;
|
||||||
|
|
||||||
|
static int auth_none(ssh_session session,
|
||||||
|
const char *user,
|
||||||
|
void *userdata)
|
||||||
|
{
|
||||||
|
ssh_string banner = NULL;
|
||||||
|
|
||||||
|
(void)user; /* unused */
|
||||||
|
(void)userdata; /* unused */
|
||||||
|
|
||||||
|
ssh_set_auth_methods(session,
|
||||||
|
SSH_AUTH_METHOD_PASSWORD | SSH_AUTH_METHOD_GSSAPI_MIC);
|
||||||
|
|
||||||
|
banner = ssh_string_from_char("Banner Example\n");
|
||||||
|
if (banner != NULL) {
|
||||||
|
ssh_send_issue_banner(session, banner);
|
||||||
|
}
|
||||||
|
ssh_string_free(banner);
|
||||||
|
|
||||||
|
return SSH_AUTH_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
static int auth_password(ssh_session session, const char *user,
|
static int auth_password(ssh_session session, const char *user,
|
||||||
const char *password, void *userdata){
|
const char *password, void *userdata){
|
||||||
(void)userdata;
|
(void)userdata;
|
||||||
@@ -60,6 +89,7 @@ static int auth_password(ssh_session session, const char *user,
|
|||||||
return SSH_AUTH_DENIED;
|
return SSH_AUTH_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WITH_GSSAPI
|
||||||
static int auth_gssapi_mic(ssh_session session, const char *user, const char *principal, void *userdata){
|
static int auth_gssapi_mic(ssh_session session, const char *user, const char *principal, void *userdata){
|
||||||
ssh_gssapi_creds creds = ssh_gssapi_get_creds(session);
|
ssh_gssapi_creds creds = ssh_gssapi_get_creds(session);
|
||||||
(void)userdata;
|
(void)userdata;
|
||||||
@@ -72,6 +102,7 @@ static int auth_gssapi_mic(ssh_session session, const char *user, const char *pr
|
|||||||
authenticated = 1;
|
authenticated = 1;
|
||||||
return SSH_AUTH_SUCCESS;
|
return SSH_AUTH_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int pty_request(ssh_session session, ssh_channel channel, const char *term,
|
static int pty_request(ssh_session session, ssh_channel channel, const char *term,
|
||||||
int x,int y, int px, int py, void *userdata){
|
int x,int y, int px, int py, void *userdata){
|
||||||
@@ -165,6 +196,14 @@ static struct argp_option options[] = {
|
|||||||
.doc = "Get verbose output.",
|
.doc = "Get verbose output.",
|
||||||
.group = 0
|
.group = 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "config",
|
||||||
|
.key = 'f',
|
||||||
|
.arg = "FILE",
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "Configuration file to use.",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
{NULL, 0, NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -191,6 +230,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
|||||||
case 'v':
|
case 'v':
|
||||||
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "3");
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "3");
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
ssh_bind_options_parse_config(sshbind, arg);
|
||||||
|
break;
|
||||||
case ARGP_KEY_ARG:
|
case ARGP_KEY_ARG:
|
||||||
if (state->arg_num >= 1) {
|
if (state->arg_num >= 1) {
|
||||||
/* Too many arguments. */
|
/* Too many arguments. */
|
||||||
@@ -221,12 +263,15 @@ int main(int argc, char **argv){
|
|||||||
ssh_event mainloop;
|
ssh_event mainloop;
|
||||||
struct ssh_server_callbacks_struct cb = {
|
struct ssh_server_callbacks_struct cb = {
|
||||||
.userdata = NULL,
|
.userdata = NULL,
|
||||||
|
.auth_none_function = auth_none,
|
||||||
.auth_password_function = auth_password,
|
.auth_password_function = auth_password,
|
||||||
|
#ifdef WITH_GSSAPI
|
||||||
.auth_gssapi_mic_function = auth_gssapi_mic,
|
.auth_gssapi_mic_function = auth_gssapi_mic,
|
||||||
|
#endif
|
||||||
.channel_open_request_session_function = new_session_channel
|
.channel_open_request_session_function = new_session_channel
|
||||||
};
|
};
|
||||||
|
|
||||||
char buf[2048];
|
char buf[BUF_SIZE];
|
||||||
int i;
|
int i;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@@ -282,19 +327,24 @@ int main(int argc, char **argv){
|
|||||||
} else
|
} else
|
||||||
printf("Authenticated and got a channel\n");
|
printf("Authenticated and got a channel\n");
|
||||||
do{
|
do{
|
||||||
i=ssh_channel_read(chan,buf, 2048, 0);
|
i=ssh_channel_read(chan, buf, sizeof(buf) - 1, 0);
|
||||||
if(i>0) {
|
if(i>0) {
|
||||||
ssh_channel_write(chan, buf, i);
|
if (ssh_channel_write(chan, buf, i) == SSH_ERROR) {
|
||||||
if (write(1,buf,i) < 0) {
|
printf("error writing to channel\n");
|
||||||
printf("error writing to buffer\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf[i] = '\0';
|
||||||
|
printf("%s", buf);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
if (buf[0] == '\x0d') {
|
if (buf[0] == '\x0d') {
|
||||||
if (write(1, "\n", 1) < 0) {
|
if (ssh_channel_write(chan, "\n", 1) == SSH_ERROR) {
|
||||||
printf("error writing to buffer\n");
|
printf("error writing to channel\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
ssh_channel_write(chan, "\n", 1);
|
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (i>0);
|
} while (i>0);
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ clients must be made or how a client should react.
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 2048
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SSHD_USER "libssh"
|
#define SSHD_USER "libssh"
|
||||||
#define SSHD_PASSWORD "libssh"
|
#define SSHD_PASSWORD "libssh"
|
||||||
|
|
||||||
@@ -293,7 +297,7 @@ int main(int argc, char **argv){
|
|||||||
ssh_bind sshbind;
|
ssh_bind sshbind;
|
||||||
ssh_message message;
|
ssh_message message;
|
||||||
ssh_channel chan=0;
|
ssh_channel chan=0;
|
||||||
char buf[2048];
|
char buf[BUF_SIZE];
|
||||||
int auth=0;
|
int auth=0;
|
||||||
int shell=0;
|
int shell=0;
|
||||||
int i;
|
int i;
|
||||||
@@ -365,9 +369,9 @@ int main(int argc, char **argv){
|
|||||||
}
|
}
|
||||||
} while(!chan);
|
} while(!chan);
|
||||||
|
|
||||||
if(!chan) {
|
if (!chan) {
|
||||||
printf("Error: cleint did not ask for a channel session (%s)\n",
|
printf("Error: client did not ask for a channel session (%s)\n",
|
||||||
ssh_get_error(session));
|
ssh_get_error(session));
|
||||||
ssh_finalize();
|
ssh_finalize();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -399,7 +403,7 @@ int main(int argc, char **argv){
|
|||||||
|
|
||||||
printf("it works !\n");
|
printf("it works !\n");
|
||||||
do{
|
do{
|
||||||
i=ssh_channel_read(chan,buf, 2048, 0);
|
i=ssh_channel_read(chan,buf, sizeof(buf), 0);
|
||||||
if(i>0) {
|
if(i>0) {
|
||||||
if(*buf == '' || *buf == '')
|
if(*buf == '' || *buf == '')
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ program.
|
|||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
#include "examples_common.h"
|
#include "examples_common.h"
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 16384
|
||||||
|
#endif
|
||||||
|
|
||||||
static int verbosity = 0;
|
static int verbosity = 0;
|
||||||
static const char *createcommand =
|
static const char *createcommand =
|
||||||
"rm -fr /tmp/libssh_tests && mkdir /tmp/libssh_tests && "
|
"rm -fr /tmp/libssh_tests && mkdir /tmp/libssh_tests && "
|
||||||
@@ -102,7 +106,7 @@ static void create_files(ssh_session session){
|
|||||||
|
|
||||||
static int fetch_files(ssh_session session){
|
static int fetch_files(ssh_session session){
|
||||||
int size;
|
int size;
|
||||||
char buffer[16384];
|
char buffer[BUF_SIZE];
|
||||||
int mode;
|
int mode;
|
||||||
char *filename;
|
char *filename;
|
||||||
int r;
|
int r;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ int main(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = ssh_channel_new(session);;
|
channel = ssh_channel_new(session);
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
866
examples/ssh_X11_client.c
Normal file
866
examples/ssh_X11_client.c
Normal file
@@ -0,0 +1,866 @@
|
|||||||
|
/*
|
||||||
|
* ssh.c - Simple example of SSH X11 client using libssh
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Marco Fortina
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
* In addition, as a special exception, the copyright holders give
|
||||||
|
* permission to link the code of portions of this program with the
|
||||||
|
* OpenSSL library under certain conditions as described in each
|
||||||
|
* individual source file, and distribute linked combinations
|
||||||
|
* including the two.
|
||||||
|
* You must obey the GNU General Public License in all respects
|
||||||
|
* for all of the code used other than OpenSSL. * If you modify
|
||||||
|
* file(s) with this exception, you may extend this exception to your
|
||||||
|
* version of the file(s), but you are not obligated to do so. * If you
|
||||||
|
* do not wish to do so, delete this exception statement from your
|
||||||
|
* version. * If you delete this exception statement from all source
|
||||||
|
* files in the program, then also delete it here.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* ssh_X11_client
|
||||||
|
* ==============
|
||||||
|
*
|
||||||
|
* AUTHOR URL
|
||||||
|
* https://gitlab.com/marco.fortina/libssh-x11-client/
|
||||||
|
*
|
||||||
|
* This is a simple example of SSH X11 client using libssh.
|
||||||
|
*
|
||||||
|
* Features:
|
||||||
|
*
|
||||||
|
* - support local display (e.g. :0)
|
||||||
|
* - support remote display (e.g. localhost:10.0)
|
||||||
|
* - using callbacks and event polling to significantly reduce CPU utilization
|
||||||
|
* - use X11 forwarding with authentication spoofing (like openssh)
|
||||||
|
*
|
||||||
|
* Note:
|
||||||
|
*
|
||||||
|
* - part of this code was inspired by openssh's one.
|
||||||
|
*
|
||||||
|
* Dependencies:
|
||||||
|
*
|
||||||
|
* - gcc >= 7.5.0
|
||||||
|
* - libssh >= 0.8.0
|
||||||
|
* - libssh-dev >= 0.8.0
|
||||||
|
*
|
||||||
|
* To Build:
|
||||||
|
* gcc -o ssh_X11_client ssh_X11_client.c -lssh -g
|
||||||
|
*
|
||||||
|
* Donations:
|
||||||
|
*
|
||||||
|
* If you liked this work and wish to support the developer please donate to:
|
||||||
|
* Bitcoin: 1N2rQimKbeUQA8N2LU5vGopYQJmZsBM2d6
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <poll.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <libssh/libssh.h>
|
||||||
|
#include <libssh/callbacks.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data Structures and Macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _PATH_UNIX_X "/tmp/.X11-unix/X%d"
|
||||||
|
#define _XAUTH_CMD "/usr/bin/xauth list %s 2>/dev/null"
|
||||||
|
|
||||||
|
typedef struct item {
|
||||||
|
ssh_channel channel;
|
||||||
|
int fd_in;
|
||||||
|
int fd_out;
|
||||||
|
int protected;
|
||||||
|
struct item *next;
|
||||||
|
} node_t;
|
||||||
|
|
||||||
|
node_t *node = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mutex
|
||||||
|
*/
|
||||||
|
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function declarations
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Linked nodes to manage channel/fd tuples */
|
||||||
|
static void insert_item(ssh_channel channel, int fd_in, int fd_out, int protected);
|
||||||
|
static void delete_item(ssh_channel channel);
|
||||||
|
static node_t * search_item(ssh_channel channel);
|
||||||
|
|
||||||
|
/* X11 Display */
|
||||||
|
const char * ssh_gai_strerror(int gaierr);
|
||||||
|
static int x11_get_proto(const char *display, char **_proto, char **_data);
|
||||||
|
static void set_nodelay(int fd);
|
||||||
|
static int connect_local_xsocket_path(const char *pathname);
|
||||||
|
static int connect_local_xsocket(int display_number);
|
||||||
|
static int x11_connect_display(void);
|
||||||
|
|
||||||
|
/* Send data to channel */
|
||||||
|
static int copy_fd_to_channel_callback(int fd, int revents, void *userdata);
|
||||||
|
|
||||||
|
/* Read data from channel */
|
||||||
|
static int copy_channel_to_fd_callback(ssh_session session, ssh_channel channel, void *data, uint32_t len, int is_stderr, void *userdata);
|
||||||
|
|
||||||
|
/* EOF&Close channel */
|
||||||
|
static void channel_close_callback(ssh_session session, ssh_channel channel, void *userdata);
|
||||||
|
|
||||||
|
/* X11 Request */
|
||||||
|
static ssh_channel x11_open_request_callback(ssh_session session, const char *shost, int sport, void *userdata);
|
||||||
|
|
||||||
|
/* Main loop */
|
||||||
|
static int main_loop(ssh_channel channel);
|
||||||
|
|
||||||
|
/* Internals */
|
||||||
|
int64_t _current_timestamp(void);
|
||||||
|
|
||||||
|
/* Global variables */
|
||||||
|
const char *hostname = NULL;
|
||||||
|
int enableX11 = 1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Callbacks Data Structures
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* SSH Channel Callbacks */
|
||||||
|
struct ssh_channel_callbacks_struct channel_cb =
|
||||||
|
{
|
||||||
|
.channel_data_function = copy_channel_to_fd_callback,
|
||||||
|
.channel_eof_function = channel_close_callback,
|
||||||
|
.channel_close_function = channel_close_callback,
|
||||||
|
.userdata = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
/* SSH Callbacks */
|
||||||
|
struct ssh_callbacks_struct cb =
|
||||||
|
{
|
||||||
|
.channel_open_request_x11_function = x11_open_request_callback,
|
||||||
|
.userdata = NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SSH Event Context
|
||||||
|
*/
|
||||||
|
|
||||||
|
short events = POLLIN | POLLPRI | POLLERR | POLLHUP | POLLNVAL;
|
||||||
|
ssh_event event;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal data structures
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct termios _saved_tio;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Internal functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
int64_t
|
||||||
|
_current_timestamp(void) {
|
||||||
|
struct timeval tv;
|
||||||
|
int64_t milliseconds;
|
||||||
|
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
milliseconds = (int64_t)(tv.tv_sec) * 1000 + (tv.tv_usec / 1000);
|
||||||
|
|
||||||
|
return milliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_logging_callback(int priority, const char *function, const char *buffer, void *userdata)
|
||||||
|
{
|
||||||
|
FILE *fp = NULL;
|
||||||
|
char buf[100];
|
||||||
|
int64_t milliseconds;
|
||||||
|
|
||||||
|
time_t now = time (0);
|
||||||
|
|
||||||
|
(void)userdata;
|
||||||
|
|
||||||
|
strftime(buf, 100, "%Y-%m-%d %H:%M:%S", localtime (&now));
|
||||||
|
|
||||||
|
fp = fopen("debug.log","a");
|
||||||
|
if(fp == NULL)
|
||||||
|
{
|
||||||
|
printf("Error!");
|
||||||
|
exit(-11);
|
||||||
|
}
|
||||||
|
|
||||||
|
milliseconds = _current_timestamp();
|
||||||
|
|
||||||
|
fprintf(fp, "[%s.%jd, %d] %s: %s\n", buf, milliseconds, priority, function, buffer);
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_enter_term_raw_mode(void)
|
||||||
|
{
|
||||||
|
struct termios tio;
|
||||||
|
int ret = tcgetattr(fileno(stdin), &tio);
|
||||||
|
if (ret != -1) {
|
||||||
|
_saved_tio = tio;
|
||||||
|
tio.c_iflag |= IGNPAR;
|
||||||
|
tio.c_iflag &= ~(ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXANY | IXOFF);
|
||||||
|
#ifdef IUCLC
|
||||||
|
tio.c_iflag &= ~IUCLC;
|
||||||
|
#endif
|
||||||
|
tio.c_lflag &= ~(ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHONL);
|
||||||
|
#ifdef IEXTEN
|
||||||
|
tio.c_lflag &= ~IEXTEN;
|
||||||
|
#endif
|
||||||
|
tio.c_oflag &= ~OPOST;
|
||||||
|
tio.c_cc[VMIN] = 1;
|
||||||
|
tio.c_cc[VTIME] = 0;
|
||||||
|
ret = tcsetattr(fileno(stdin), TCSADRAIN, &tio);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_leave_term_raw_mode(void)
|
||||||
|
{
|
||||||
|
int ret = tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
insert_item(ssh_channel channel, int fd_in, int fd_out, int protected)
|
||||||
|
{
|
||||||
|
node_t *node_iterator = NULL, *new = NULL;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
|
|
||||||
|
if (node == NULL) {
|
||||||
|
/* Calloc ensure that node is full of 0 */
|
||||||
|
node = (node_t *) calloc(1, sizeof(node_t));
|
||||||
|
node->channel = channel;
|
||||||
|
node->fd_in = fd_in;
|
||||||
|
node->fd_out = fd_out;
|
||||||
|
node->protected = protected;
|
||||||
|
node->next = NULL;
|
||||||
|
} else {
|
||||||
|
node_iterator = node;
|
||||||
|
while (node_iterator->next != NULL)
|
||||||
|
node_iterator = node_iterator->next;
|
||||||
|
/* Create the new node */
|
||||||
|
new = (node_t *) malloc(sizeof(node_t));
|
||||||
|
new->channel = channel;
|
||||||
|
new->fd_in = fd_in;
|
||||||
|
new->fd_out = fd_out;
|
||||||
|
new->protected = protected;
|
||||||
|
new->next = NULL;
|
||||||
|
node_iterator->next = new;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_item(ssh_channel channel)
|
||||||
|
{
|
||||||
|
node_t *current = NULL, *previous = NULL;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
|
|
||||||
|
for (current = node; current; previous = current, current = current->next) {
|
||||||
|
if (current->channel != channel)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (previous == NULL)
|
||||||
|
node = current->next;
|
||||||
|
else
|
||||||
|
previous->next = current->next;
|
||||||
|
|
||||||
|
free(current);
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static node_t *
|
||||||
|
search_item(ssh_channel channel)
|
||||||
|
{
|
||||||
|
node_t *current = node;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
|
|
||||||
|
while (current != NULL) {
|
||||||
|
if (current->channel == channel) {
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
return current;
|
||||||
|
} else {
|
||||||
|
current = current->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_nodelay(int fd)
|
||||||
|
{
|
||||||
|
int opt;
|
||||||
|
socklen_t optlen;
|
||||||
|
|
||||||
|
optlen = sizeof(opt);
|
||||||
|
if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, &optlen) == -1) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "getsockopt TCP_NODELAY: %.100s", strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (opt == 1) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "fd %d is TCP_NODELAY", fd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
opt = 1;
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "fd %d setting TCP_NODELAY", fd);
|
||||||
|
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt)) == -1)
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "setsockopt TCP_NODELAY: %.100s", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
ssh_gai_strerror(int gaierr)
|
||||||
|
{
|
||||||
|
if (gaierr == EAI_SYSTEM && errno != 0)
|
||||||
|
return strerror(errno);
|
||||||
|
return gai_strerror(gaierr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
x11_get_proto(const char *display, char **_proto, char **_cookie)
|
||||||
|
{
|
||||||
|
char cmd[1024], line[512], xdisplay[512];
|
||||||
|
static char proto[512], cookie[512];
|
||||||
|
FILE *f = NULL;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
*_proto = proto;
|
||||||
|
*_cookie = cookie;
|
||||||
|
|
||||||
|
proto[0] = cookie[0] = '\0';
|
||||||
|
|
||||||
|
if (strncmp(display, "localhost:", 10) == 0) {
|
||||||
|
if ((ret = snprintf(xdisplay, sizeof(xdisplay), "unix:%s", display + 10)) < 0 || (size_t)ret >= sizeof(xdisplay)) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "display name too long. display: %s", display);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
display = xdisplay;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(cmd, sizeof(cmd), _XAUTH_CMD, display);
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "xauth cmd: %s", cmd);
|
||||||
|
|
||||||
|
f = popen(cmd, "r");
|
||||||
|
if (f && fgets(line, sizeof(line), f) && sscanf(line, "%*s %511s %511s", proto, cookie) == 2) {
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f) pclose(f);
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "proto: %s - cookie: %s - ret: %d", proto, cookie, ret);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
connect_local_xsocket_path(const char *pathname)
|
||||||
|
{
|
||||||
|
int sock;
|
||||||
|
struct sockaddr_un addr;
|
||||||
|
|
||||||
|
sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
if (sock == -1) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "socket: %.100s", strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
addr.sun_family = AF_UNIX;
|
||||||
|
addr.sun_path[0] = '\0';
|
||||||
|
/* pathname is guaranteed to be initialized and larger than addr.sun_path[108] */
|
||||||
|
memcpy(addr.sun_path + 1, pathname, sizeof(addr.sun_path) - 1);
|
||||||
|
if (connect(sock, (struct sockaddr *)&addr, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(pathname)) == 0)
|
||||||
|
return sock;
|
||||||
|
close(sock);
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "connect %.100s: %.100s", addr.sun_path, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
connect_local_xsocket(int display_number)
|
||||||
|
{
|
||||||
|
char buf[1024] = {0};
|
||||||
|
snprintf(buf, sizeof(buf), _PATH_UNIX_X, display_number);
|
||||||
|
return connect_local_xsocket_path(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
x11_connect_display(void)
|
||||||
|
{
|
||||||
|
int display_number;
|
||||||
|
const char *display = NULL;
|
||||||
|
char buf[1024], *cp = NULL;
|
||||||
|
struct addrinfo hints, *ai = NULL, *aitop = NULL;
|
||||||
|
char strport[NI_MAXSERV];
|
||||||
|
int gaierr = 0, sock = 0;
|
||||||
|
|
||||||
|
/* Try to open a socket for the local X server. */
|
||||||
|
display = getenv("DISPLAY");
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "display: %s", display);
|
||||||
|
|
||||||
|
if (!display) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if it is a unix domain socket. */
|
||||||
|
if (strncmp(display, "unix:", 5) == 0 || display[0] == ':') {
|
||||||
|
/* Connect to the unix domain socket. */
|
||||||
|
if (sscanf(strrchr(display, ':') + 1, "%d", &display_number) != 1) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "Could not parse display number from DISPLAY: %.100s", display);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "display_number: %d", display_number);
|
||||||
|
|
||||||
|
/* Create a socket. */
|
||||||
|
sock = connect_local_xsocket(display_number);
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "socket: %d", sock);
|
||||||
|
|
||||||
|
if (sock < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* OK, we now have a connection to the display. */
|
||||||
|
return sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Connect to an inet socket. */
|
||||||
|
strncpy(buf, display, sizeof(buf) - 1);
|
||||||
|
cp = strchr(buf, ':');
|
||||||
|
if (!cp) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "Could not find ':' in DISPLAY: %.100s", display);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*cp = 0;
|
||||||
|
if (sscanf(cp + 1, "%d", &display_number) != 1) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "Could not parse display number from DISPLAY: %.100s", display);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Look up the host address */
|
||||||
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
hints.ai_family = AF_INET;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
snprintf(strport, sizeof(strport), "%u", 6000 + display_number);
|
||||||
|
if ((gaierr = getaddrinfo(buf, strport, &hints, &aitop)) != 0) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "%.100s: unknown host. (%s)", buf, ssh_gai_strerror(gaierr));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (ai = aitop; ai; ai = ai->ai_next) {
|
||||||
|
/* Create a socket. */
|
||||||
|
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
|
||||||
|
if (sock == -1) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "socket: %.100s", strerror(errno));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* Connect it to the display. */
|
||||||
|
if (connect(sock, ai->ai_addr, ai->ai_addrlen) == -1) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "connect %.100s port %u: %.100s", buf, 6000 + display_number, strerror(errno));
|
||||||
|
close(sock);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* Success */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
freeaddrinfo(aitop);
|
||||||
|
if (!ai) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "connect %.100s port %u: %.100s", buf, 6000 + display_number, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
set_nodelay(sock);
|
||||||
|
return sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
copy_fd_to_channel_callback(int fd, int revents, void *userdata)
|
||||||
|
{
|
||||||
|
ssh_channel channel = (ssh_channel)userdata;
|
||||||
|
char buf[2097152];
|
||||||
|
int sz = 0, ret = 0;
|
||||||
|
|
||||||
|
node_t *temp_node = search_item(channel);
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "event: %d - fd: %d", revents, fd);
|
||||||
|
|
||||||
|
if (!channel) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "channel does not exist.");
|
||||||
|
if (temp_node->protected == 0) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fcntl(fd, F_GETFD) == -1) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "fcntl error. fd: %d", fd);
|
||||||
|
ssh_channel_close(channel);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((revents & POLLIN) || (revents & POLLPRI)) {
|
||||||
|
sz = read(fd, buf, sizeof(buf));
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "sz: %d", sz);
|
||||||
|
if (sz > 0) {
|
||||||
|
ret = ssh_channel_write(channel, buf, sz);
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "channel_write ret: %d", ret);
|
||||||
|
} else if (sz < 0) {
|
||||||
|
ssh_channel_close(channel);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
/* sz = 0. Why the hell I'm here? */
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "Why the hell am I here?: sz: %d", sz);
|
||||||
|
if (temp_node->protected == 0) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((revents & POLLHUP) || (revents & POLLNVAL) || (revents & POLLERR)) {
|
||||||
|
ssh_channel_close(channel);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
copy_channel_to_fd_callback(ssh_session session, ssh_channel channel, void *data, uint32_t len, int is_stderr, void *userdata)
|
||||||
|
{
|
||||||
|
node_t *temp_node = NULL;
|
||||||
|
int fd, sz;
|
||||||
|
|
||||||
|
(void)session;
|
||||||
|
(void)is_stderr;
|
||||||
|
(void)userdata;
|
||||||
|
|
||||||
|
temp_node = search_item(channel);
|
||||||
|
|
||||||
|
fd = temp_node->fd_out;
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "len: %d - fd: %d - is_stderr: %d", len, fd, is_stderr);
|
||||||
|
|
||||||
|
sz = write(fd, data, len);
|
||||||
|
|
||||||
|
return sz;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
channel_close_callback(ssh_session session, ssh_channel channel, void *userdata)
|
||||||
|
{
|
||||||
|
node_t *temp_node = NULL;
|
||||||
|
|
||||||
|
(void)session;
|
||||||
|
(void)userdata;
|
||||||
|
|
||||||
|
temp_node = search_item(channel);
|
||||||
|
|
||||||
|
if (temp_node != NULL) {
|
||||||
|
int fd = temp_node->fd_in;
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "fd: %d", fd);
|
||||||
|
|
||||||
|
delete_item(channel);
|
||||||
|
ssh_event_remove_fd(event, fd);
|
||||||
|
|
||||||
|
if (temp_node->protected == 0) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ssh_channel
|
||||||
|
x11_open_request_callback(ssh_session session, const char *shost, int sport, void *userdata)
|
||||||
|
{
|
||||||
|
ssh_channel channel = NULL;
|
||||||
|
int sock;
|
||||||
|
|
||||||
|
(void)shost;
|
||||||
|
(void)sport;
|
||||||
|
(void)userdata;
|
||||||
|
|
||||||
|
channel = ssh_channel_new(session);
|
||||||
|
|
||||||
|
sock = x11_connect_display();
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "sock: %d", sock);
|
||||||
|
|
||||||
|
insert_item(channel, sock, sock, 0);
|
||||||
|
|
||||||
|
ssh_event_add_fd(event, sock, events, copy_fd_to_channel_callback, channel);
|
||||||
|
ssh_event_add_session(event, session);
|
||||||
|
|
||||||
|
ssh_add_channel_callbacks(channel, &channel_cb);
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MAIN LOOP
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
main_loop(ssh_channel channel)
|
||||||
|
{
|
||||||
|
ssh_session session = ssh_channel_get_session(channel);
|
||||||
|
|
||||||
|
insert_item(channel, fileno(stdin), fileno(stdout), 1);
|
||||||
|
|
||||||
|
ssh_callbacks_init(&channel_cb);
|
||||||
|
ssh_set_channel_callbacks(channel, &channel_cb);
|
||||||
|
|
||||||
|
event = ssh_event_new();
|
||||||
|
if (event == NULL) {
|
||||||
|
printf("Couldn't get a event\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssh_event_add_fd(event, fileno(stdin), events, copy_fd_to_channel_callback, channel) != SSH_OK) {
|
||||||
|
printf("Couldn't add an fd to the event\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ssh_event_add_session(event, session) != SSH_OK) {
|
||||||
|
printf("Couldn't add the session to the event\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (ssh_event_dopoll(event, 1000) == SSH_ERROR) {
|
||||||
|
printf("Error : %s\n", ssh_get_error(session));
|
||||||
|
/* fall through */
|
||||||
|
}
|
||||||
|
} while (!ssh_channel_is_closed(channel));
|
||||||
|
|
||||||
|
delete_item(channel);
|
||||||
|
ssh_event_remove_fd(event, fileno(stdin));
|
||||||
|
ssh_event_remove_session(event, session);
|
||||||
|
ssh_event_free(event);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USAGE
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"Usage : ssh-X11-client [options] [login@]hostname\n"
|
||||||
|
"sample X11 client - libssh-%s\n"
|
||||||
|
"Options :\n"
|
||||||
|
" -l user : Specifies the user to log in as on the remote machine.\n"
|
||||||
|
" -p port : Port to connect to on the remote host.\n"
|
||||||
|
" -v : Verbose mode. Multiple -v options increase the verbosity. The maximum is 5.\n"
|
||||||
|
" -C : Requests compression of all data.\n"
|
||||||
|
" -x : Disables X11 forwarding.\n"
|
||||||
|
"\n",
|
||||||
|
ssh_version(0));
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int opts(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
while ((i = getopt(argc,argv,"x")) != -1) {
|
||||||
|
switch(i) {
|
||||||
|
case 'x':
|
||||||
|
enableX11 = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Unknown option %c\n", optopt);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind < argc) {
|
||||||
|
hostname = argv[optind++];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hostname == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MAIN
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
char *password = NULL;
|
||||||
|
|
||||||
|
ssh_session session = NULL;
|
||||||
|
ssh_channel channel = NULL;
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
const char *display = NULL;
|
||||||
|
char *proto = NULL, *cookie = NULL;
|
||||||
|
|
||||||
|
ssh_set_log_callback(_logging_callback);
|
||||||
|
ret = ssh_init();
|
||||||
|
if (ret != SSH_OK) return ret;
|
||||||
|
|
||||||
|
session = ssh_new();
|
||||||
|
if (session == NULL) exit(-1);
|
||||||
|
|
||||||
|
if (ssh_options_getopt(session, &argc, argv) || opts(argc, argv)) {
|
||||||
|
fprintf(stderr, "Error parsing command line: %s\n", ssh_get_error(session));
|
||||||
|
ssh_free(session);
|
||||||
|
ssh_finalize();
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssh_options_set(session, SSH_OPTIONS_HOST, hostname) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ssh_connect(session);
|
||||||
|
if (ret != SSH_OK) {
|
||||||
|
fprintf(stderr, "Connection failed : %s\n", ssh_get_error(session));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
password = getpass("Password: ");
|
||||||
|
ret = ssh_userauth_password(session, NULL, password);
|
||||||
|
if (ret != SSH_AUTH_SUCCESS) {
|
||||||
|
fprintf(stderr, "Error authenticating with password: %s\n", ssh_get_error(session));
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
channel = ssh_channel_new(session);
|
||||||
|
if (channel == NULL) return SSH_ERROR;
|
||||||
|
|
||||||
|
ret = ssh_channel_open_session(channel);
|
||||||
|
if (ret != SSH_OK) return ret;
|
||||||
|
|
||||||
|
ret = ssh_channel_request_pty(channel);
|
||||||
|
if (ret != SSH_OK) return ret;
|
||||||
|
|
||||||
|
ret = ssh_channel_change_pty_size(channel, 80, 24);
|
||||||
|
if (ret != SSH_OK) return ret;
|
||||||
|
|
||||||
|
if (enableX11 == 1) {
|
||||||
|
display = getenv("DISPLAY");
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "display: %s", display);
|
||||||
|
|
||||||
|
if (display) {
|
||||||
|
ssh_callbacks_init(&cb);
|
||||||
|
ret = ssh_set_callbacks(session, &cb);
|
||||||
|
if (ret != SSH_OK) return ret;
|
||||||
|
|
||||||
|
if (x11_get_proto(display, &proto, &cookie) != 0) {
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "Using fake authentication data for X11 forwarding");
|
||||||
|
proto = NULL;
|
||||||
|
cookie = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, __func__, "proto: %s - cookie: %s", proto, cookie);
|
||||||
|
/* See https://gitlab.com/libssh/libssh-mirror/-/blob/master/src/channels.c#L2062 for details. */
|
||||||
|
ret = ssh_channel_request_x11(channel, 0, proto, cookie, 0);
|
||||||
|
if (ret != SSH_OK) return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = _enter_term_raw_mode();
|
||||||
|
if (ret != 0) exit(-1);
|
||||||
|
|
||||||
|
ret = ssh_channel_request_shell(channel);
|
||||||
|
if (ret != SSH_OK) return ret;
|
||||||
|
|
||||||
|
ret = main_loop(channel);
|
||||||
|
if (ret != SSH_OK) return ret;
|
||||||
|
|
||||||
|
_leave_term_raw_mode();
|
||||||
|
|
||||||
|
ssh_channel_close(channel);
|
||||||
|
ssh_channel_free(channel);
|
||||||
|
ssh_disconnect(session);
|
||||||
|
ssh_free(session);
|
||||||
|
ssh_finalize();
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@@ -44,9 +45,10 @@
|
|||||||
#include "examples_common.h"
|
#include "examples_common.h"
|
||||||
#define MAXCMD 10
|
#define MAXCMD 10
|
||||||
|
|
||||||
static char *host;
|
static char *host = NULL;
|
||||||
static char *user;
|
static char *user = NULL;
|
||||||
static char *cmds[MAXCMD];
|
static char *cmds[MAXCMD];
|
||||||
|
static char *config_file = NULL;
|
||||||
static struct termios terminal;
|
static struct termios terminal;
|
||||||
|
|
||||||
static char *pcap_file = NULL;
|
static char *pcap_file = NULL;
|
||||||
@@ -81,7 +83,7 @@ static void add_cmd(char *cmd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds[n] = strdup(cmd);
|
cmds[n] = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
@@ -94,6 +96,7 @@ static void usage(void)
|
|||||||
" -p port : connect to port\n"
|
" -p port : connect to port\n"
|
||||||
" -d : use DSS to verify host public key\n"
|
" -d : use DSS to verify host public key\n"
|
||||||
" -r : use RSA to verify host public key\n"
|
" -r : use RSA to verify host public key\n"
|
||||||
|
" -F file : parse configuration file instead of default one\n"
|
||||||
#ifdef WITH_PCAP
|
#ifdef WITH_PCAP
|
||||||
" -P file : create a pcap debugging file\n"
|
" -P file : create a pcap debugging file\n"
|
||||||
#endif
|
#endif
|
||||||
@@ -110,11 +113,14 @@ static int opts(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
while((i = getopt(argc,argv,"T:P:")) != -1) {
|
while((i = getopt(argc,argv,"T:P:F:")) != -1) {
|
||||||
switch(i){
|
switch(i){
|
||||||
case 'P':
|
case 'P':
|
||||||
pcap_file = optarg;
|
pcap_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
config_file = optarg;
|
||||||
|
break;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
case 'T':
|
case 'T':
|
||||||
proxycommand = optarg;
|
proxycommand = optarg;
|
||||||
@@ -122,7 +128,7 @@ static int opts(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown option %c\n", optopt);
|
fprintf(stderr, "Unknown option %c\n", optopt);
|
||||||
usage();
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
@@ -134,7 +140,7 @@ static int opts(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (host == NULL) {
|
if (host == NULL) {
|
||||||
usage();
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -169,22 +175,25 @@ static void do_exit(int i)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssh_channel chan;
|
|
||||||
static int signal_delayed = 0;
|
static int signal_delayed = 0;
|
||||||
|
|
||||||
|
#ifdef SIGWINCH
|
||||||
static void sigwindowchanged(int i)
|
static void sigwindowchanged(int i)
|
||||||
{
|
{
|
||||||
(void) i;
|
(void) i;
|
||||||
signal_delayed = 1;
|
signal_delayed = 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void setsignal(void)
|
static void setsignal(void)
|
||||||
{
|
{
|
||||||
|
#ifdef SIGWINCH
|
||||||
signal(SIGWINCH, sigwindowchanged);
|
signal(SIGWINCH, sigwindowchanged);
|
||||||
|
#endif
|
||||||
signal_delayed = 0;
|
signal_delayed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sizechanged(void)
|
static void sizechanged(ssh_channel chan)
|
||||||
{
|
{
|
||||||
struct winsize win = {
|
struct winsize win = {
|
||||||
.ws_row = 0,
|
.ws_row = 0,
|
||||||
@@ -222,7 +231,7 @@ static void select_loop(ssh_session session,ssh_channel channel)
|
|||||||
|
|
||||||
while (ssh_channel_is_open(channel)) {
|
while (ssh_channel_is_open(channel)) {
|
||||||
if (signal_delayed) {
|
if (signal_delayed) {
|
||||||
sizechanged();
|
sizechanged(channel);
|
||||||
}
|
}
|
||||||
rc = ssh_event_dopoll(event, 60000);
|
rc = ssh_event_dopoll(event, 60000);
|
||||||
if (rc == SSH_ERROR) {
|
if (rc == SSH_ERROR) {
|
||||||
@@ -262,10 +271,9 @@ static void shell(ssh_session session)
|
|||||||
ssh_channel_free(channel);
|
ssh_channel_free(channel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chan = channel;
|
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
ssh_channel_request_pty(channel);
|
ssh_channel_request_pty(channel);
|
||||||
sizechanged();
|
sizechanged(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ssh_channel_request_shell(channel)) {
|
if (ssh_channel_request_shell(channel)) {
|
||||||
@@ -290,14 +298,12 @@ static void shell(ssh_session session)
|
|||||||
static void batch_shell(ssh_session session)
|
static void batch_shell(ssh_session session)
|
||||||
{
|
{
|
||||||
ssh_channel channel;
|
ssh_channel channel;
|
||||||
char buffer[1024];
|
char buffer[PATH_MAX];
|
||||||
size_t i;
|
size_t i;
|
||||||
int s = 0;
|
int s = 0;
|
||||||
|
|
||||||
for (i = 0; i < MAXCMD && cmds[i]; ++i) {
|
for (i = 0; i < MAXCMD && cmds[i]; ++i) {
|
||||||
s += snprintf(buffer + s, sizeof(buffer) - s, "%s ", cmds[i]);
|
s += snprintf(buffer + s, sizeof(buffer) - s, "%s ", cmds[i]);
|
||||||
free(cmds[i]);
|
|
||||||
cmds[i] = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channel = ssh_channel_new(session);
|
channel = ssh_channel_new(session);
|
||||||
@@ -326,7 +332,7 @@ static int client(ssh_session session)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0) {
|
if (ssh_options_set(session, SSH_OPTIONS_HOST, host) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (proxycommand != NULL) {
|
if (proxycommand != NULL) {
|
||||||
@@ -334,7 +340,13 @@ static int client(ssh_session session)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ssh_options_parse_config(session, NULL);
|
/* Parse configuration file if specified: The command-line options will
|
||||||
|
* overwrite items loaded from configuration file */
|
||||||
|
if (config_file != NULL) {
|
||||||
|
ssh_options_parse_config(session, config_file);
|
||||||
|
} else {
|
||||||
|
ssh_options_parse_config(session, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (ssh_connect(session)) {
|
if (ssh_connect(session)) {
|
||||||
fprintf(stderr, "Connection failed : %s\n", ssh_get_error(session));
|
fprintf(stderr, "Connection failed : %s\n", ssh_get_error(session));
|
||||||
@@ -398,18 +410,20 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
|
|
||||||
|
ssh_init();
|
||||||
session = ssh_new();
|
session = ssh_new();
|
||||||
|
|
||||||
ssh_callbacks_init(&cb);
|
ssh_callbacks_init(&cb);
|
||||||
ssh_set_callbacks(session,&cb);
|
ssh_set_callbacks(session,&cb);
|
||||||
|
|
||||||
if (ssh_options_getopt(session, &argc, argv)) {
|
if (ssh_options_getopt(session, &argc, argv) || opts(argc, argv)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error parsing command line: %s\n",
|
"Error parsing command line: %s\n",
|
||||||
ssh_get_error(session));
|
ssh_get_error(session));
|
||||||
|
ssh_free(session);
|
||||||
|
ssh_finalize();
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
opts(argc, argv);
|
|
||||||
signal(SIGTERM, do_exit);
|
signal(SIGTERM, do_exit);
|
||||||
|
|
||||||
set_pcap(session);
|
set_pcap(session);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ The goal is to show the API in action.
|
|||||||
#ifdef HAVE_LIBUTIL_H
|
#ifdef HAVE_LIBUTIL_H
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <pthread.h>
|
||||||
#ifdef HAVE_PTY_H
|
#ifdef HAVE_PTY_H
|
||||||
#include <pty.h>
|
#include <pty.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -40,6 +41,10 @@ The goal is to show the API in action.
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 1048576
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef KEYS_FOLDER
|
#ifndef KEYS_FOLDER
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define KEYS_FOLDER
|
#define KEYS_FOLDER
|
||||||
@@ -48,9 +53,6 @@ The goal is to show the API in action.
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USER "myuser"
|
|
||||||
#define PASS "mypassword"
|
|
||||||
#define BUF_SIZE 1048576
|
|
||||||
#define SESSION_END (SSH_CLOSED | SSH_CLOSED_ERROR)
|
#define SESSION_END (SSH_CLOSED | SSH_CLOSED_ERROR)
|
||||||
#define SFTP_SERVER_PATH "/usr/lib/sftp-server"
|
#define SFTP_SERVER_PATH "/usr/lib/sftp-server"
|
||||||
|
|
||||||
@@ -75,6 +77,8 @@ static void set_default_keys(ssh_bind sshbind,
|
|||||||
}
|
}
|
||||||
#define DEF_STR_SIZE 1024
|
#define DEF_STR_SIZE 1024
|
||||||
char authorizedkeys[DEF_STR_SIZE] = {0};
|
char authorizedkeys[DEF_STR_SIZE] = {0};
|
||||||
|
char username[128] = "myuser";
|
||||||
|
char password[128] = "mypassword";
|
||||||
#ifdef HAVE_ARGP_H
|
#ifdef HAVE_ARGP_H
|
||||||
const char *argp_program_version = "libssh server example "
|
const char *argp_program_version = "libssh server example "
|
||||||
SSH_STRINGIFY(LIBSSH_VERSION);
|
SSH_STRINGIFY(LIBSSH_VERSION);
|
||||||
@@ -137,6 +141,22 @@ static struct argp_option options[] = {
|
|||||||
.doc = "Set the authorized keys file.",
|
.doc = "Set the authorized keys file.",
|
||||||
.group = 0
|
.group = 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "user",
|
||||||
|
.key = 'u',
|
||||||
|
.arg = "USERNAME",
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "Set expected username.",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "pass",
|
||||||
|
.key = 'P',
|
||||||
|
.arg = "PASSWORD",
|
||||||
|
.flags = 0,
|
||||||
|
.doc = "Set expected password.",
|
||||||
|
.group = 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "no-default-keys",
|
.name = "no-default-keys",
|
||||||
.key = 'n',
|
.key = 'n',
|
||||||
@@ -193,6 +213,12 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
|||||||
case 'a':
|
case 'a':
|
||||||
strncpy(authorizedkeys, arg, DEF_STR_SIZE-1);
|
strncpy(authorizedkeys, arg, DEF_STR_SIZE-1);
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
strncpy(username, arg, sizeof(username) - 1);
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
strncpy(password, arg, sizeof(password) - 1);
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR,
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR,
|
||||||
"3");
|
"3");
|
||||||
@@ -226,6 +252,89 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
|||||||
|
|
||||||
/* Our argp parser. */
|
/* Our argp parser. */
|
||||||
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
|
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
|
||||||
|
#else
|
||||||
|
static int parse_opt(int argc, char **argv, ssh_bind sshbind) {
|
||||||
|
int no_default_keys = 0;
|
||||||
|
int rsa_already_set = 0;
|
||||||
|
int dsa_already_set = 0;
|
||||||
|
int ecdsa_already_set = 0;
|
||||||
|
int key;
|
||||||
|
|
||||||
|
while((key = getopt(argc, argv, "a:d:e:k:np:P:r:u:v")) != -1) {
|
||||||
|
if (key == 'n') {
|
||||||
|
no_default_keys = 1;
|
||||||
|
} else if (key == 'p') {
|
||||||
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT_STR, optarg);
|
||||||
|
} else if (key == 'd') {
|
||||||
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, optarg);
|
||||||
|
dsa_already_set = 1;
|
||||||
|
} else if (key == 'k') {
|
||||||
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_HOSTKEY, optarg);
|
||||||
|
/* We can't track the types of keys being added with this
|
||||||
|
option, so let's ensure we keep the keys we're adding
|
||||||
|
by just not setting the default keys */
|
||||||
|
no_default_keys = 1;
|
||||||
|
} else if (key == 'r') {
|
||||||
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, optarg);
|
||||||
|
rsa_already_set = 1;
|
||||||
|
} else if (key == 'e') {
|
||||||
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_ECDSAKEY, optarg);
|
||||||
|
ecdsa_already_set = 1;
|
||||||
|
} else if (key == 'a') {
|
||||||
|
strncpy(authorizedkeys, optarg, DEF_STR_SIZE-1);
|
||||||
|
} else if (key == 'u') {
|
||||||
|
strncpy(username, optarg, sizeof(username) - 1);
|
||||||
|
} else if (key == 'P') {
|
||||||
|
strncpy(password, optarg, sizeof(password) - 1);
|
||||||
|
} else if (key == 'v') {
|
||||||
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR,
|
||||||
|
"3");
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key != -1) {
|
||||||
|
printf("Usage: %s [OPTION...] BINDADDR\n"
|
||||||
|
"libssh %s -- a Secure Shell protocol implementation\n"
|
||||||
|
"\n"
|
||||||
|
" -a, --authorizedkeys=FILE Set the authorized keys file.\n"
|
||||||
|
" -d, --dsakey=FILE Set the dsa key.\n"
|
||||||
|
" -e, --ecdsakey=FILE Set the ecdsa key.\n"
|
||||||
|
" -k, --hostkey=FILE Set a host key. Can be used multiple times.\n"
|
||||||
|
" Implies no default keys.\n"
|
||||||
|
" -n, --no-default-keys Do not set default key locations.\n"
|
||||||
|
" -p, --port=PORT Set the port to bind.\n"
|
||||||
|
" -P, --pass=PASSWORD Set expected password.\n"
|
||||||
|
" -r, --rsakey=FILE Set the rsa key.\n"
|
||||||
|
" -u, --user=USERNAME Set expected username.\n"
|
||||||
|
" -v, --verbose Get verbose output.\n"
|
||||||
|
" -?, --help Give this help list\n"
|
||||||
|
"\n"
|
||||||
|
"Mandatory or optional arguments to long options are also mandatory or optional\n"
|
||||||
|
"for any corresponding short options.\n"
|
||||||
|
"\n"
|
||||||
|
"Report bugs to <libssh@libssh.org>.\n",
|
||||||
|
argv[0], SSH_STRINGIFY(LIBSSH_VERSION));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind != argc - 1) {
|
||||||
|
printf("Usage: %s [OPTION...] BINDADDR\n", argv[0]);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDADDR, argv[optind]);
|
||||||
|
|
||||||
|
if (!no_default_keys) {
|
||||||
|
set_default_keys(sshbind,
|
||||||
|
rsa_already_set,
|
||||||
|
dsa_already_set,
|
||||||
|
ecdsa_already_set);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif /* HAVE_ARGP_H */
|
#endif /* HAVE_ARGP_H */
|
||||||
|
|
||||||
/* A userdata struct for channel. */
|
/* A userdata struct for channel. */
|
||||||
@@ -440,7 +549,7 @@ static int auth_password(ssh_session session, const char *user,
|
|||||||
|
|
||||||
(void) session;
|
(void) session;
|
||||||
|
|
||||||
if (strcmp(user, USER) == 0 && strcmp(pass, PASS) == 0) {
|
if (strcmp(user, username) == 0 && strcmp(pass, password) == 0) {
|
||||||
sdata->authenticated = 1;
|
sdata->authenticated = 1;
|
||||||
return SSH_AUTH_SUCCESS;
|
return SSH_AUTH_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -678,18 +787,38 @@ static void handle_session(ssh_event event, ssh_session session) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WITH_FORK
|
||||||
/* SIGCHLD handler for cleaning up dead children. */
|
/* SIGCHLD handler for cleaning up dead children. */
|
||||||
static void sigchld_handler(int signo) {
|
static void sigchld_handler(int signo) {
|
||||||
(void) signo;
|
(void) signo;
|
||||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static void *session_thread(void *arg) {
|
||||||
|
ssh_session session = arg;
|
||||||
|
ssh_event event;
|
||||||
|
|
||||||
|
event = ssh_event_new();
|
||||||
|
if (event != NULL) {
|
||||||
|
/* Blocks until the SSH session ends by either
|
||||||
|
* child thread exiting, or client disconnecting. */
|
||||||
|
handle_session(event, session);
|
||||||
|
ssh_event_free(event);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Could not create polling context\n");
|
||||||
|
}
|
||||||
|
ssh_disconnect(session);
|
||||||
|
ssh_free(session);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
ssh_bind sshbind;
|
ssh_bind sshbind;
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
ssh_event event;
|
|
||||||
struct sigaction sa;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
#ifdef WITH_FORK
|
||||||
|
struct sigaction sa;
|
||||||
|
|
||||||
/* Set up SIGCHLD handler. */
|
/* Set up SIGCHLD handler. */
|
||||||
sa.sa_handler = sigchld_handler;
|
sa.sa_handler = sigchld_handler;
|
||||||
@@ -699,6 +828,7 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "Failed to register SIGCHLD handler\n");
|
fprintf(stderr, "Failed to register SIGCHLD handler\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
rc = ssh_init();
|
rc = ssh_init();
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
@@ -709,20 +839,24 @@ int main(int argc, char **argv) {
|
|||||||
sshbind = ssh_bind_new();
|
sshbind = ssh_bind_new();
|
||||||
if (sshbind == NULL) {
|
if (sshbind == NULL) {
|
||||||
fprintf(stderr, "ssh_bind_new failed\n");
|
fprintf(stderr, "ssh_bind_new failed\n");
|
||||||
|
ssh_finalize();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_ARGP_H
|
#ifdef HAVE_ARGP_H
|
||||||
argp_parse(&argp, argc, argv, 0, 0, sshbind);
|
argp_parse(&argp, argc, argv, 0, 0, sshbind);
|
||||||
#else
|
#else
|
||||||
(void) argc;
|
if (parse_opt(argc, argv, sshbind) < 0) {
|
||||||
(void) argv;
|
ssh_bind_free(sshbind);
|
||||||
|
ssh_finalize();
|
||||||
set_default_keys(sshbind, 0, 0, 0);
|
return 1;
|
||||||
|
}
|
||||||
#endif /* HAVE_ARGP_H */
|
#endif /* HAVE_ARGP_H */
|
||||||
|
|
||||||
if(ssh_bind_listen(sshbind) < 0) {
|
if(ssh_bind_listen(sshbind) < 0) {
|
||||||
fprintf(stderr, "%s\n", ssh_get_error(sshbind));
|
fprintf(stderr, "%s\n", ssh_get_error(sshbind));
|
||||||
|
ssh_bind_free(sshbind);
|
||||||
|
ssh_finalize();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,6 +869,9 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
/* Blocks until there is a new incoming connection. */
|
/* Blocks until there is a new incoming connection. */
|
||||||
if(ssh_bind_accept(sshbind, session) != SSH_ERROR) {
|
if(ssh_bind_accept(sshbind, session) != SSH_ERROR) {
|
||||||
|
#ifdef WITH_FORK
|
||||||
|
ssh_event event;
|
||||||
|
|
||||||
switch(fork()) {
|
switch(fork()) {
|
||||||
case 0:
|
case 0:
|
||||||
/* Remove the SIGCHLD handler inherited from parent. */
|
/* Remove the SIGCHLD handler inherited from parent. */
|
||||||
@@ -760,6 +897,16 @@ int main(int argc, char **argv) {
|
|||||||
case -1:
|
case -1:
|
||||||
fprintf(stderr, "Failed to fork\n");
|
fprintf(stderr, "Failed to fork\n");
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
pthread_t tid;
|
||||||
|
|
||||||
|
rc = pthread_create(&tid, NULL, session_thread, session);
|
||||||
|
if (rc == 0) {
|
||||||
|
pthread_detach(tid);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "Failed to pthread_create\n");
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "%s\n", ssh_get_error(sshbind));
|
fprintf(stderr, "%s\n", ssh_get_error(sshbind));
|
||||||
}
|
}
|
||||||
@@ -23,17 +23,39 @@ clients must be made or how a client should react.
|
|||||||
#include <libssh/libssh.h>
|
#include <libssh/libssh.h>
|
||||||
#include <libssh/server.h>
|
#include <libssh/server.h>
|
||||||
#include <libssh/callbacks.h>
|
#include <libssh/callbacks.h>
|
||||||
#include <libssh/channels.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_ARGP_H
|
#ifdef HAVE_ARGP_H
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 16384
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
|
||||||
|
|
||||||
|
#ifndef __unused__
|
||||||
|
# ifdef HAVE_UNUSED_ATTRIBUTE
|
||||||
|
# define __unused__ __attribute__((unused))
|
||||||
|
# else /* HAVE_UNUSED_ATTRIBUTE */
|
||||||
|
# define __unused__
|
||||||
|
# endif /* HAVE_UNUSED_ATTRIBUTE */
|
||||||
|
#endif /* __unused__ */
|
||||||
|
|
||||||
|
#ifndef UNUSED_PARAM
|
||||||
|
#define UNUSED_PARAM(param) param __unused__
|
||||||
|
#endif /* UNUSED_PARAM */
|
||||||
|
|
||||||
#ifndef KEYS_FOLDER
|
#ifndef KEYS_FOLDER
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define KEYS_FOLDER
|
#define KEYS_FOLDER
|
||||||
@@ -66,11 +88,18 @@ static struct cleanup_node_struct *cleanup_stack = NULL;
|
|||||||
|
|
||||||
static void _close_socket(struct event_fd_data_struct event_fd_data);
|
static void _close_socket(struct event_fd_data_struct event_fd_data);
|
||||||
|
|
||||||
static void cleanup_push(struct cleanup_node_struct** head_ref, struct event_fd_data_struct *new_data) {
|
static void
|
||||||
|
cleanup_push(struct cleanup_node_struct** head_ref,
|
||||||
|
struct event_fd_data_struct *new_data)
|
||||||
|
{
|
||||||
// Allocate memory for node
|
// Allocate memory for node
|
||||||
struct cleanup_node_struct *new_node = malloc(sizeof *new_node);
|
struct cleanup_node_struct *new_node = malloc(sizeof *new_node);
|
||||||
|
|
||||||
new_node->next = (*head_ref);
|
if (*head_ref != NULL) {
|
||||||
|
new_node->next = *head_ref;
|
||||||
|
} else {
|
||||||
|
new_node->next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy new_data
|
// Copy new_data
|
||||||
new_node->data = new_data;
|
new_node->data = new_data;
|
||||||
@@ -79,7 +108,9 @@ static void cleanup_push(struct cleanup_node_struct** head_ref, struct event_fd_
|
|||||||
(*head_ref) = new_node;
|
(*head_ref) = new_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_cleanup(struct cleanup_node_struct **head_ref) {
|
static void
|
||||||
|
do_cleanup(struct cleanup_node_struct **head_ref)
|
||||||
|
{
|
||||||
struct cleanup_node_struct *current = (*head_ref);
|
struct cleanup_node_struct *current = (*head_ref);
|
||||||
struct cleanup_node_struct *previous = NULL, *gone = NULL;
|
struct cleanup_node_struct *previous = NULL, *gone = NULL;
|
||||||
|
|
||||||
@@ -118,16 +149,22 @@ static void do_cleanup(struct cleanup_node_struct **head_ref) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int auth_password(ssh_session session, const char *user,
|
static int
|
||||||
const char *password, void *userdata) {
|
auth_password(ssh_session session,
|
||||||
(void)userdata;
|
const char *user,
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== auth_password", "Authenticating user %s pwd %s",user, password);
|
const char *password,
|
||||||
if (strcmp(user,USER) == 0 && strcmp(password, PASSWORD) == 0){
|
UNUSED_PARAM(void *userdata))
|
||||||
|
{
|
||||||
|
_ssh_log(SSH_LOG_PROTOCOL,
|
||||||
|
"=== auth_password", "Authenticating user %s pwd %s",
|
||||||
|
user,
|
||||||
|
password);
|
||||||
|
if (strcmp(user, USER) == 0 && strcmp(password, PASSWORD) == 0) {
|
||||||
authenticated = true;
|
authenticated = true;
|
||||||
printf("Authenticated\n");
|
printf("Authenticated\n");
|
||||||
return SSH_AUTH_SUCCESS;
|
return SSH_AUTH_SUCCESS;
|
||||||
}
|
}
|
||||||
if (tries >= 3){
|
if (tries >= 3) {
|
||||||
printf("Too many authentication tries\n");
|
printf("Too many authentication tries\n");
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
error_set = true;
|
error_set = true;
|
||||||
@@ -137,25 +174,34 @@ static int auth_password(ssh_session session, const char *user,
|
|||||||
return SSH_AUTH_DENIED;
|
return SSH_AUTH_DENIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int auth_gssapi_mic(ssh_session session, const char *user, const char *principal, void *userdata) {
|
static int
|
||||||
|
auth_gssapi_mic(ssh_session session,
|
||||||
|
const char *user,
|
||||||
|
const char *principal,
|
||||||
|
UNUSED_PARAM(void *userdata))
|
||||||
|
{
|
||||||
ssh_gssapi_creds creds = ssh_gssapi_get_creds(session);
|
ssh_gssapi_creds creds = ssh_gssapi_get_creds(session);
|
||||||
(void)userdata;
|
printf("Authenticating user %s with gssapi principal %s\n",
|
||||||
printf("Authenticating user %s with gssapi principal %s\n", user, principal);
|
user, principal);
|
||||||
if (creds != NULL)
|
if (creds != NULL) {
|
||||||
printf("Received some gssapi credentials\n");
|
printf("Received some gssapi credentials\n");
|
||||||
else
|
} else {
|
||||||
printf("Not received any forwardable creds\n");
|
printf("Not received any forwardable creds\n");
|
||||||
|
}
|
||||||
printf("authenticated\n");
|
printf("authenticated\n");
|
||||||
authenticated = true;
|
authenticated = true;
|
||||||
return SSH_AUTH_SUCCESS;
|
return SSH_AUTH_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int subsystem_request(ssh_session session, ssh_channel channel, const char *subsystem, void *userdata) {
|
static int
|
||||||
(void)session;
|
subsystem_request(UNUSED_PARAM(ssh_session session),
|
||||||
(void)channel;
|
UNUSED_PARAM(ssh_channel channel),
|
||||||
//(void)subsystem;
|
const char *subsystem,
|
||||||
(void)userdata;
|
UNUSED_PARAM(void *userdata))
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== subsystem_request", "Channel subsystem reqeuest: %s", subsystem);
|
{
|
||||||
|
_ssh_log(SSH_LOG_PROTOCOL,
|
||||||
|
"=== subsystem_request", "Channel subsystem request: %s",
|
||||||
|
subsystem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,9 +209,10 @@ struct ssh_channel_callbacks_struct channel_cb = {
|
|||||||
.channel_subsystem_request_function = subsystem_request
|
.channel_subsystem_request_function = subsystem_request
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssh_channel new_session_channel(ssh_session session, void *userdata) {
|
static ssh_channel
|
||||||
(void)session;
|
new_session_channel(UNUSED_PARAM(ssh_session session),
|
||||||
(void)userdata;
|
UNUSED_PARAM(void *userdata))
|
||||||
|
{
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== subsystem_request", "Session channel request");
|
_ssh_log(SSH_LOG_PROTOCOL, "=== subsystem_request", "Session channel request");
|
||||||
/* For TCP forward only there seems to be no need for a session channel */
|
/* For TCP forward only there seems to be no need for a session channel */
|
||||||
/*if(chan != NULL)
|
/*if(chan != NULL)
|
||||||
@@ -178,18 +225,25 @@ static ssh_channel new_session_channel(ssh_session session, void *userdata) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stack_socket_close(UNUSED_PARAM(ssh_session session),
|
static void
|
||||||
struct event_fd_data_struct *event_fd_data)
|
stack_socket_close(UNUSED_PARAM(ssh_session session),
|
||||||
|
struct event_fd_data_struct *event_fd_data)
|
||||||
{
|
{
|
||||||
if (event_fd_data->stacked != 1) {
|
if (event_fd_data->stacked != 1) {
|
||||||
_ssh_log(SSH_LOG_FUNCTIONS, "=== stack_socket_close", "Closing fd = %d sockets_cnt = %d", *event_fd_data->p_fd, sockets_cnt);
|
_ssh_log(SSH_LOG_FUNCTIONS, "=== stack_socket_close",
|
||||||
|
"Closing fd = %d sockets_cnt = %d", *event_fd_data->p_fd,
|
||||||
|
sockets_cnt);
|
||||||
event_fd_data->stacked = 1;
|
event_fd_data->stacked = 1;
|
||||||
cleanup_push(&cleanup_stack, event_fd_data);
|
cleanup_push(&cleanup_stack, event_fd_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _close_socket(struct event_fd_data_struct event_fd_data) {
|
static void
|
||||||
_ssh_log(SSH_LOG_FUNCTIONS, "=== close_socket", "Closing fd = %d sockets_cnt = %d", *event_fd_data.p_fd, sockets_cnt);
|
_close_socket(struct event_fd_data_struct event_fd_data)
|
||||||
|
{
|
||||||
|
_ssh_log(SSH_LOG_FUNCTIONS, "=== close_socket",
|
||||||
|
"Closing fd = %d sockets_cnt = %d", *event_fd_data.p_fd,
|
||||||
|
sockets_cnt);
|
||||||
ssh_event_remove_fd(mainloop, *event_fd_data.p_fd);
|
ssh_event_remove_fd(mainloop, *event_fd_data.p_fd);
|
||||||
sockets_cnt--;
|
sockets_cnt--;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -200,51 +254,75 @@ static void _close_socket(struct event_fd_data_struct event_fd_data) {
|
|||||||
(*event_fd_data.p_fd) = SSH_INVALID_SOCKET;
|
(*event_fd_data.p_fd) = SSH_INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int service_request(ssh_session session, const char *service, void *userdata) {
|
static int
|
||||||
(void)session;
|
service_request(UNUSED_PARAM(ssh_session session),
|
||||||
//(void)service;
|
const char *service,
|
||||||
(void)userdata;
|
UNUSED_PARAM(void *userdata))
|
||||||
|
{
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== service_request", "Service request: %s", service);
|
_ssh_log(SSH_LOG_PROTOCOL, "=== service_request", "Service request: %s", service);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void global_request(ssh_session session, ssh_message message, void *userdata) {
|
static void
|
||||||
(void)session;
|
global_request(UNUSED_PARAM(ssh_session session),
|
||||||
(void)userdata;
|
ssh_message message,
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== global_request", "Global request, message type: %d", ssh_message_type(message));
|
UNUSED_PARAM(void *userdata))
|
||||||
|
{
|
||||||
|
_ssh_log(SSH_LOG_PROTOCOL,
|
||||||
|
"=== global_request", "Global request, message type: %d",
|
||||||
|
ssh_message_type(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void my_channel_close_function(ssh_session session, ssh_channel channel, void *userdata) {
|
static void
|
||||||
|
my_channel_close_function(ssh_session session,
|
||||||
|
UNUSED_PARAM(ssh_channel channel),
|
||||||
|
void *userdata)
|
||||||
|
{
|
||||||
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
||||||
(void)session;
|
|
||||||
|
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== my_channel_close_function", "Channel %d:%d closed by remote. State=%d", channel->local_channel, channel->remote_channel, channel->state);
|
_ssh_log(SSH_LOG_PROTOCOL,
|
||||||
|
"=== my_channel_close_function",
|
||||||
|
"Channel closed by remote.");
|
||||||
|
|
||||||
stack_socket_close(session, event_fd_data);
|
stack_socket_close(session, event_fd_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void my_channel_eof_function(ssh_session session, ssh_channel channel, void *userdata) {
|
static void
|
||||||
|
my_channel_eof_function(ssh_session session,
|
||||||
|
UNUSED_PARAM(ssh_channel channel),
|
||||||
|
void *userdata)
|
||||||
|
{
|
||||||
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
||||||
(void)session;
|
|
||||||
|
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== my_channel_eof_function", "Got EOF on channel %d:%d. Shuting down write on socket (fd = %d).", channel->local_channel, channel->remote_channel, *event_fd_data->p_fd);
|
_ssh_log(SSH_LOG_PROTOCOL,
|
||||||
|
"=== my_channel_eof_function",
|
||||||
|
"Got EOF on channel. Shutting down write on socket (fd = %d).",
|
||||||
|
*event_fd_data->p_fd);
|
||||||
|
|
||||||
stack_socket_close(session, event_fd_data);
|
stack_socket_close(session, event_fd_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void my_channel_exit_status_function(ssh_session session, ssh_channel channel, int exit_status, void *userdata) {
|
static void
|
||||||
|
my_channel_exit_status_function(UNUSED_PARAM(ssh_session session),
|
||||||
|
UNUSED_PARAM(ssh_channel channel),
|
||||||
|
int exit_status,
|
||||||
|
void *userdata)
|
||||||
|
{
|
||||||
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
||||||
(void)session;
|
|
||||||
|
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== my_channel_exit_status_function", "Got exit status %d on channel %d:%d fd = %d.", exit_status, channel->local_channel, channel->remote_channel, *event_fd_data->p_fd);
|
_ssh_log(SSH_LOG_PROTOCOL,
|
||||||
|
"=== my_channel_exit_status_function",
|
||||||
|
"Got exit status %d on channel fd = %d.",
|
||||||
|
exit_status, *event_fd_data->p_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int my_channel_data_function(ssh_session session,
|
static int
|
||||||
ssh_channel channel,
|
my_channel_data_function(ssh_session session,
|
||||||
void *data,
|
UNUSED_PARAM(ssh_channel channel),
|
||||||
uint32_t len,
|
void *data,
|
||||||
UNUSED_PARAM(int is_stderr),
|
uint32_t len,
|
||||||
void *userdata)
|
UNUSED_PARAM(int is_stderr),
|
||||||
|
void *userdata)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
||||||
@@ -253,12 +331,18 @@ static int my_channel_data_function(ssh_session session,
|
|||||||
fprintf(stderr, "Why we're here? Stacked = %d\n", event_fd_data->stacked);
|
fprintf(stderr, "Why we're here? Stacked = %d\n", event_fd_data->stacked);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== my_channel_data_function", "%d bytes waiting on channel %d:%d for reading. Fd = %d",len, channel->local_channel, channel->remote_channel, *event_fd_data->p_fd);
|
_ssh_log(SSH_LOG_PROTOCOL,
|
||||||
|
"=== my_channel_data_function",
|
||||||
|
"%d bytes waiting on channel for reading. Fd = %d",
|
||||||
|
len,
|
||||||
|
*event_fd_data->p_fd);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
i = send(*event_fd_data->p_fd, data, len, 0);
|
i = send(*event_fd_data->p_fd, data, len, 0);
|
||||||
}
|
}
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
_ssh_log(SSH_LOG_WARNING, "=== my_channel_data_function", "Writing to tcp socket %d: %s", *event_fd_data->p_fd, strerror(errno));
|
_ssh_log(SSH_LOG_WARNING, "=== my_channel_data_function",
|
||||||
|
"Writing to tcp socket %d: %s", *event_fd_data->p_fd,
|
||||||
|
strerror(errno));
|
||||||
stack_socket_close(session, event_fd_data);
|
stack_socket_close(session, event_fd_data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -267,15 +351,16 @@ static int my_channel_data_function(ssh_session session,
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int my_fd_data_function(UNUSED_PARAM(socket_t fd),
|
static int
|
||||||
int revents,
|
my_fd_data_function(UNUSED_PARAM(socket_t fd),
|
||||||
void *userdata)
|
int revents,
|
||||||
|
void *userdata)
|
||||||
{
|
{
|
||||||
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
||||||
ssh_channel channel = event_fd_data->channel;
|
ssh_channel channel = event_fd_data->channel;
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
int len, i, wr;
|
int len, i, wr;
|
||||||
char buf[16384];
|
char buf[BUF_SIZE];
|
||||||
int blocking;
|
int blocking;
|
||||||
|
|
||||||
if (channel == NULL) {
|
if (channel == NULL) {
|
||||||
@@ -313,8 +398,10 @@ static int my_fd_data_function(UNUSED_PARAM(socket_t fd),
|
|||||||
blocking = ssh_is_blocking(session);
|
blocking = ssh_is_blocking(session);
|
||||||
ssh_set_blocking(session, 0);
|
ssh_set_blocking(session, 0);
|
||||||
|
|
||||||
_ssh_log(SSH_LOG_FUNCTIONS, "=== my_fd_data_function", "Trying to read from tcp socket fd = %d... (Channel %d:%d state=%d)",
|
_ssh_log(SSH_LOG_FUNCTIONS,
|
||||||
*event_fd_data->p_fd, channel->local_channel, channel->remote_channel, channel->state);
|
"=== my_fd_data_function",
|
||||||
|
"Trying to read from tcp socket fd = %d",
|
||||||
|
*event_fd_data->p_fd);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct sockaddr from;
|
struct sockaddr from;
|
||||||
int fromlen = sizeof(from);
|
int fromlen = sizeof(from);
|
||||||
@@ -338,7 +425,7 @@ static int my_fd_data_function(UNUSED_PARAM(socket_t fd),
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
wr += i;
|
wr += i;
|
||||||
_ssh_log(SSH_LOG_FUNCTIONS, "=== my_fd_data_function", "channel_write (%d from %d)", wr, len);
|
_ssh_log(SSH_LOG_FUNCTIONS, "=== my_fd_data_function", "ssh_channel_write (%d from %d)", wr, len);
|
||||||
} while (i > 0 && wr < len);
|
} while (i > 0 && wr < len);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -360,7 +447,9 @@ static int my_fd_data_function(UNUSED_PARAM(socket_t fd),
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int open_tcp_socket(ssh_message msg) {
|
static int
|
||||||
|
open_tcp_socket(ssh_message msg)
|
||||||
|
{
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
int forwardsock = -1;
|
int forwardsock = -1;
|
||||||
struct hostent *host;
|
struct hostent *host;
|
||||||
@@ -401,17 +490,20 @@ static int open_tcp_socket(ssh_message msg) {
|
|||||||
return forwardsock;
|
return forwardsock;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int message_callback(ssh_session session, ssh_message message, void *userdata) {
|
static int
|
||||||
|
message_callback(UNUSED_PARAM(ssh_session session),
|
||||||
|
ssh_message message,
|
||||||
|
UNUSED_PARAM(void *userdata))
|
||||||
|
{
|
||||||
ssh_channel channel;
|
ssh_channel channel;
|
||||||
int socket_fd, *pFd;
|
int socket_fd, *pFd;
|
||||||
struct ssh_channel_callbacks_struct *cb_chan;
|
struct ssh_channel_callbacks_struct *cb_chan;
|
||||||
struct event_fd_data_struct *event_fd_data;
|
struct event_fd_data_struct *event_fd_data;
|
||||||
(void)session;
|
|
||||||
(void)message;
|
|
||||||
(void)userdata;
|
|
||||||
|
|
||||||
_ssh_log(SSH_LOG_PACKET, "=== message_callback", "Message type: %d", ssh_message_type(message));
|
_ssh_log(SSH_LOG_PACKET, "=== message_callback", "Message type: %d",
|
||||||
_ssh_log(SSH_LOG_PACKET, "=== message_callback", "Message Subtype: %d", ssh_message_subtype(message));
|
ssh_message_type(message));
|
||||||
|
_ssh_log(SSH_LOG_PACKET, "=== message_callback", "Message Subtype: %d",
|
||||||
|
ssh_message_subtype(message));
|
||||||
if (ssh_message_type(message) == SSH_REQUEST_CHANNEL_OPEN) {
|
if (ssh_message_type(message) == SSH_REQUEST_CHANNEL_OPEN) {
|
||||||
_ssh_log(SSH_LOG_PROTOCOL, "=== message_callback", "channel_request_open");
|
_ssh_log(SSH_LOG_PROTOCOL, "=== message_callback", "channel_request_open");
|
||||||
|
|
||||||
@@ -433,6 +525,13 @@ static int message_callback(ssh_session session, ssh_message message, void *user
|
|||||||
pFd = malloc(sizeof *pFd);
|
pFd = malloc(sizeof *pFd);
|
||||||
cb_chan = malloc(sizeof *cb_chan);
|
cb_chan = malloc(sizeof *cb_chan);
|
||||||
event_fd_data = malloc(sizeof *event_fd_data);
|
event_fd_data = malloc(sizeof *event_fd_data);
|
||||||
|
if (pFd == NULL || cb_chan == NULL || event_fd_data == NULL) {
|
||||||
|
SAFE_FREE(pFd);
|
||||||
|
SAFE_FREE(cb_chan);
|
||||||
|
SAFE_FREE(event_fd_data);
|
||||||
|
close(socket_fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
(*pFd) = socket_fd;
|
(*pFd) = socket_fd;
|
||||||
event_fd_data->channel = channel;
|
event_fd_data->channel = channel;
|
||||||
@@ -515,7 +614,9 @@ static struct argp_option options[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Parse a single option. */
|
/* Parse a single option. */
|
||||||
static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
static error_t
|
||||||
|
parse_opt (int key, char *arg, struct argp_state *state)
|
||||||
|
{
|
||||||
/* Get the input argument from argp_parse, which we
|
/* Get the input argument from argp_parse, which we
|
||||||
* know is a pointer to our arguments structure.
|
* know is a pointer to our arguments structure.
|
||||||
*/
|
*/
|
||||||
@@ -561,7 +662,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
|||||||
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
|
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
|
||||||
#endif /* HAVE_ARGP_H */
|
#endif /* HAVE_ARGP_H */
|
||||||
|
|
||||||
int main(int argc, char **argv){
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
ssh_session session;
|
ssh_session session;
|
||||||
ssh_bind sshbind;
|
ssh_bind sshbind;
|
||||||
struct ssh_server_callbacks_struct cb = {
|
struct ssh_server_callbacks_struct cb = {
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ clients must be made or how a client should react.
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "examples_common.h"
|
#include "examples_common.h"
|
||||||
|
|
||||||
|
#ifndef BUF_SIZE
|
||||||
|
#define BUF_SIZE 4096
|
||||||
|
#endif
|
||||||
|
|
||||||
char *host;
|
char *host;
|
||||||
const char *desthost="localhost";
|
const char *desthost="localhost";
|
||||||
const char *port="22";
|
const char *port="22";
|
||||||
@@ -77,7 +82,7 @@ static int opts(int argc, char **argv){
|
|||||||
static void select_loop(ssh_session session,ssh_channel channel){
|
static void select_loop(ssh_session session,ssh_channel channel){
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
char buffer[4096];
|
char buffer[BUF_SIZE];
|
||||||
/* channels will be set to the channels to poll.
|
/* channels will be set to the channels to poll.
|
||||||
* outchannels will contain the result of the poll
|
* outchannels will contain the result of the poll
|
||||||
*/
|
*/
|
||||||
@@ -233,9 +238,10 @@ void set_pcap(ssh_session session){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_pcap(void);
|
void cleanup_pcap(void);
|
||||||
void cleanup_pcap(){
|
void cleanup_pcap(void)
|
||||||
|
{
|
||||||
ssh_pcap_file_free(pcap);
|
ssh_pcap_file_free(pcap);
|
||||||
pcap=NULL;
|
pcap = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -31,3 +31,9 @@ install(
|
|||||||
headers
|
headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libssh_version.h.cmake
|
||||||
|
${libssh_BINARY_DIR}/include/libssh/libssh_version.h
|
||||||
|
@ONLY)
|
||||||
|
install(FILES ${libssh_BINARY_DIR}/include/libssh/libssh_version.h
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${APPLICATION_NAME}
|
||||||
|
COMPONENT headers)
|
||||||
|
|||||||
@@ -70,6 +70,10 @@
|
|||||||
#define SSH_AGENT_RSA_SHA2_256 0x02
|
#define SSH_AGENT_RSA_SHA2_256 0x02
|
||||||
#define SSH_AGENT_RSA_SHA2_512 0x04
|
#define SSH_AGENT_RSA_SHA2_512 0x04
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ssh_agent_struct {
|
struct ssh_agent_struct {
|
||||||
struct ssh_socket_struct *sock;
|
struct ssh_socket_struct *sock;
|
||||||
ssh_buffer ident;
|
ssh_buffer ident;
|
||||||
@@ -77,7 +81,6 @@ struct ssh_agent_struct {
|
|||||||
ssh_channel channel;
|
ssh_channel channel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
/* agent.c */
|
/* agent.c */
|
||||||
/**
|
/**
|
||||||
* @brief Create a new ssh agent structure.
|
* @brief Create a new ssh agent structure.
|
||||||
@@ -104,7 +107,7 @@ void ssh_agent_free(struct ssh_agent_struct *agent);
|
|||||||
*/
|
*/
|
||||||
int ssh_agent_is_running(struct ssh_session_struct *session);
|
int ssh_agent_is_running(struct ssh_session_struct *session);
|
||||||
|
|
||||||
int ssh_agent_get_ident_count(struct ssh_session_struct *session);
|
uint32_t ssh_agent_get_ident_count(struct ssh_session_struct *session);
|
||||||
|
|
||||||
ssh_key ssh_agent_get_next_ident(struct ssh_session_struct *session,
|
ssh_key ssh_agent_get_next_ident(struct ssh_session_struct *session,
|
||||||
char **comment);
|
char **comment);
|
||||||
@@ -115,6 +118,9 @@ ssh_key ssh_agent_get_first_ident(struct ssh_session_struct *session,
|
|||||||
ssh_string ssh_agent_sign_data(ssh_session session,
|
ssh_string ssh_agent_sign_data(ssh_session session,
|
||||||
const ssh_key pubkey,
|
const ssh_key pubkey,
|
||||||
struct ssh_buffer_struct *data);
|
struct ssh_buffer_struct *data);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __AGENT_H */
|
#endif /* __AGENT_H */
|
||||||
|
|||||||
@@ -23,6 +23,10 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "libssh/callbacks.h"
|
#include "libssh/callbacks.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_userauth_banner);
|
SSH_PACKET_CALLBACK(ssh_packet_userauth_banner);
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_userauth_failure);
|
SSH_PACKET_CALLBACK(ssh_packet_userauth_failure);
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_userauth_success);
|
SSH_PACKET_CALLBACK(ssh_packet_userauth_success);
|
||||||
@@ -100,4 +104,8 @@ enum ssh_auth_service_state_e {
|
|||||||
SSH_AUTH_SERVICE_DENIED,
|
SSH_AUTH_SERVICE_DENIED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* AUTH_H_ */
|
#endif /* AUTH_H_ */
|
||||||
|
|||||||
@@ -25,9 +25,16 @@
|
|||||||
#include "libssh/libgcrypt.h"
|
#include "libssh/libgcrypt.h"
|
||||||
#include "libssh/libmbedcrypto.h"
|
#include "libssh/libmbedcrypto.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
bignum ssh_make_string_bn(ssh_string string);
|
bignum ssh_make_string_bn(ssh_string string);
|
||||||
ssh_string ssh_make_bignum_string(bignum num);
|
ssh_string ssh_make_bignum_string(bignum num);
|
||||||
void ssh_print_bignum(const char *which, const_bignum num);
|
void ssh_print_bignum(const char *which, const_bignum num);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* BIGNUM_H_ */
|
#endif /* BIGNUM_H_ */
|
||||||
|
|||||||
@@ -22,8 +22,13 @@
|
|||||||
#define BIND_H_
|
#define BIND_H_
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/kex.h"
|
||||||
#include "libssh/session.h"
|
#include "libssh/session.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ssh_bind_struct {
|
struct ssh_bind_struct {
|
||||||
struct ssh_common_struct common; /* stuff common to ssh_bind and ssh_session */
|
struct ssh_common_struct common; /* stuff common to ssh_bind and ssh_session */
|
||||||
struct ssh_bind_callbacks_struct *bind_callbacks;
|
struct ssh_bind_callbacks_struct *bind_callbacks;
|
||||||
@@ -31,7 +36,7 @@ struct ssh_bind_struct {
|
|||||||
|
|
||||||
struct ssh_poll_handle_struct *poll;
|
struct ssh_poll_handle_struct *poll;
|
||||||
/* options */
|
/* options */
|
||||||
char *wanted_methods[10];
|
char *wanted_methods[SSH_KEX_METHODS];
|
||||||
char *banner;
|
char *banner;
|
||||||
char *ecdsakey;
|
char *ecdsakey;
|
||||||
char *dsakey;
|
char *dsakey;
|
||||||
@@ -49,10 +54,15 @@ struct ssh_bind_struct {
|
|||||||
bool config_processed;
|
bool config_processed;
|
||||||
char *config_dir;
|
char *config_dir;
|
||||||
char *pubkey_accepted_key_types;
|
char *pubkey_accepted_key_types;
|
||||||
|
char* moduli_file;
|
||||||
|
int rsa_min_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ssh_poll_handle_struct *ssh_bind_get_poll(struct ssh_bind_struct
|
struct ssh_poll_handle_struct *ssh_bind_get_poll(struct ssh_bind_struct
|
||||||
*sshbind);
|
*sshbind);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* BIND_H_ */
|
#endif /* BIND_H_ */
|
||||||
|
|||||||
@@ -28,6 +28,10 @@
|
|||||||
|
|
||||||
#include "libssh/server.h"
|
#include "libssh/server.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
enum ssh_bind_config_opcode_e {
|
enum ssh_bind_config_opcode_e {
|
||||||
/* Known but not allowed in Match block */
|
/* Known but not allowed in Match block */
|
||||||
BIND_CFG_NOT_ALLOWED_IN_MATCH = -4,
|
BIND_CFG_NOT_ALLOWED_IN_MATCH = -4,
|
||||||
@@ -61,4 +65,18 @@ enum ssh_bind_config_opcode_e {
|
|||||||
*/
|
*/
|
||||||
int ssh_bind_config_parse_file(ssh_bind sshbind, const char *filename);
|
int ssh_bind_config_parse_file(ssh_bind sshbind, const char *filename);
|
||||||
|
|
||||||
|
/* @brief Parse configuration string and set the options to the given bind session
|
||||||
|
*
|
||||||
|
* @params[in] bind The ssh bind session
|
||||||
|
* @params[in] input Null terminated string containing the configuration
|
||||||
|
*
|
||||||
|
* @returns SSH_OK on successful parsing the configuration string,
|
||||||
|
* SSH_ERROR on error
|
||||||
|
*/
|
||||||
|
int ssh_bind_config_parse_string(ssh_bind bind, const char *input);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* BIND_CONFIG_H_ */
|
#endif /* BIND_CONFIG_H_ */
|
||||||
|
|||||||
@@ -49,6 +49,10 @@
|
|||||||
#define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */
|
#define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */
|
||||||
#define BLF_MAXUTILIZED ((BLF_N+2)*4) /* 576 bits */
|
#define BLF_MAXUTILIZED ((BLF_N+2)*4) /* 576 bits */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Blowfish context */
|
/* Blowfish context */
|
||||||
typedef struct BlowfishContext {
|
typedef struct BlowfishContext {
|
||||||
uint32_t S[4][256]; /* S-Boxes */
|
uint32_t S[4][256]; /* S-Boxes */
|
||||||
@@ -84,4 +88,9 @@ void ssh_blf_cbc_decrypt(ssh_blf_ctx *, uint8_t *, uint8_t *, uint32_t);
|
|||||||
uint32_t Blowfish_stream2word(const uint8_t *, uint16_t , uint16_t *);
|
uint32_t Blowfish_stream2word(const uint8_t *, uint16_t , uint16_t *);
|
||||||
|
|
||||||
#endif /* !defined(HAVE_BCRYPT_PBKDF) && !defined(HAVE_BLH_H) */
|
#endif /* !defined(HAVE_BCRYPT_PBKDF) && !defined(HAVE_BLH_H) */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _BLF_H */
|
#endif /* _BLF_H */
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
|
|
||||||
#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
|
#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
void ssh_buffer_set_secure(ssh_buffer buffer);
|
void ssh_buffer_set_secure(ssh_buffer buffer);
|
||||||
int ssh_buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
|
int ssh_buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
|
||||||
int ssh_buffer_add_u8(ssh_buffer buffer, uint8_t data);
|
int ssh_buffer_add_u8(ssh_buffer buffer, uint8_t data);
|
||||||
@@ -63,9 +67,9 @@ int ssh_buffer_prepend_data(ssh_buffer buffer, const void *data, uint32_t len);
|
|||||||
int ssh_buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
|
int ssh_buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
|
||||||
|
|
||||||
/* buffer_read_*() returns the number of bytes read, except for ssh strings */
|
/* buffer_read_*() returns the number of bytes read, except for ssh strings */
|
||||||
int ssh_buffer_get_u8(ssh_buffer buffer, uint8_t *data);
|
uint32_t ssh_buffer_get_u8(ssh_buffer buffer, uint8_t *data);
|
||||||
int ssh_buffer_get_u32(ssh_buffer buffer, uint32_t *data);
|
uint32_t ssh_buffer_get_u32(ssh_buffer buffer, uint32_t *data);
|
||||||
int ssh_buffer_get_u64(ssh_buffer buffer, uint64_t *data);
|
uint32_t ssh_buffer_get_u64(ssh_buffer buffer, uint64_t *data);
|
||||||
|
|
||||||
/* ssh_buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
|
/* ssh_buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
|
||||||
ssh_string ssh_buffer_get_ssh_string(ssh_buffer buffer);
|
ssh_string ssh_buffer_get_ssh_string(ssh_buffer buffer);
|
||||||
@@ -74,4 +78,8 @@ ssh_string ssh_buffer_get_ssh_string(ssh_buffer buffer);
|
|||||||
uint32_t ssh_buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
|
uint32_t ssh_buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
|
||||||
uint32_t ssh_buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
|
uint32_t ssh_buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* BUFFER_H_ */
|
#endif /* BUFFER_H_ */
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ typedef void (*ssh_callback_int) (int code, void *user);
|
|||||||
* @returns number of bytes processed by the callee. The remaining bytes will
|
* @returns number of bytes processed by the callee. The remaining bytes will
|
||||||
* be sent in the next callback message, when more data is available.
|
* be sent in the next callback message, when more data is available.
|
||||||
*/
|
*/
|
||||||
typedef int (*ssh_callback_data) (const void *data, size_t len, void *user);
|
typedef size_t (*ssh_callback_data) (const void *data, size_t len, void *user);
|
||||||
|
|
||||||
typedef void (*ssh_callback_int_int) (int code, int errno_code, void *user);
|
typedef void (*ssh_callback_int_int) (int code, int errno_code, void *user);
|
||||||
|
|
||||||
@@ -81,9 +81,9 @@ typedef void (*ssh_log_callback) (ssh_session session, int priority,
|
|||||||
*
|
*
|
||||||
* @param priority Priority of the log, the smaller being the more important.
|
* @param priority Priority of the log, the smaller being the more important.
|
||||||
*
|
*
|
||||||
* @param function The function name calling the the logging fucntions.
|
* @param function The function name calling the logging functions.
|
||||||
*
|
*
|
||||||
* @param message The actual message
|
* @param buffer The actual message
|
||||||
*
|
*
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
*/
|
*/
|
||||||
@@ -117,6 +117,8 @@ typedef void (*ssh_global_request_callback) (ssh_session session,
|
|||||||
* sends back an X11 connection attempt. This is a client-side API
|
* sends back an X11 connection attempt. This is a client-side API
|
||||||
* @param session current session handler
|
* @param session current session handler
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
|
* @param originator_address IP address of the machine who sent the request
|
||||||
|
* @param originator_port port number of the machine who sent the request
|
||||||
* @returns a valid ssh_channel handle if the request is to be allowed
|
* @returns a valid ssh_channel handle if the request is to be allowed
|
||||||
* @returns NULL if the request should not be allowed
|
* @returns NULL if the request should not be allowed
|
||||||
* @warning The channel pointer returned by this callback must be closed by the application.
|
* @warning The channel pointer returned by this callback must be closed by the application.
|
||||||
@@ -221,8 +223,8 @@ typedef int (*ssh_auth_gssapi_mic_callback) (ssh_session session, const char *us
|
|||||||
* @param user User that wants to authenticate
|
* @param user User that wants to authenticate
|
||||||
* @param pubkey public key used for authentication
|
* @param pubkey public key used for authentication
|
||||||
* @param signature_state SSH_PUBLICKEY_STATE_NONE if the key is not signed (simple public key probe),
|
* @param signature_state SSH_PUBLICKEY_STATE_NONE if the key is not signed (simple public key probe),
|
||||||
* SSH_PUBLICKEY_STATE_VALID if the signature is valid. Others values should be
|
* SSH_PUBLICKEY_STATE_VALID if the signature is valid. Others values should be
|
||||||
* replied with a SSH_AUTH_DENIED.
|
* replied with a SSH_AUTH_DENIED.
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
* @returns SSH_AUTH_SUCCESS Authentication is accepted.
|
* @returns SSH_AUTH_SUCCESS Authentication is accepted.
|
||||||
* @returns SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed.
|
* @returns SSH_AUTH_PARTIAL Partial authentication, more authentication means are needed.
|
||||||
@@ -268,11 +270,11 @@ typedef ssh_string (*ssh_gssapi_select_oid_callback) (ssh_session session, const
|
|||||||
int n_oid, ssh_string *oids, void *userdata);
|
int n_oid, ssh_string *oids, void *userdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief handle the negociation of a security context, server side.
|
* @brief handle the negotiation of a security context, server side.
|
||||||
* @param session current session handler
|
* @param session current session handler
|
||||||
* @param[in] input_token input token provided by client
|
* @param[in] input_token input token provided by client
|
||||||
* @param[out] output_token output of the gssapi accept_sec_context method,
|
* @param[out] output_token output of the gssapi accept_sec_context method,
|
||||||
* NULL after completion.
|
* NULL after completion.
|
||||||
* @returns SSH_OK if the token was generated correctly or accept_sec_context
|
* @returns SSH_OK if the token was generated correctly or accept_sec_context
|
||||||
* returned GSS_S_COMPLETE
|
* returned GSS_S_COMPLETE
|
||||||
* @returns SSH_ERROR in case of error
|
* @returns SSH_ERROR in case of error
|
||||||
@@ -354,6 +356,9 @@ typedef struct ssh_server_callbacks_struct *ssh_server_callbacks;
|
|||||||
* This functions sets the callback structure to use your own callback
|
* This functions sets the callback structure to use your own callback
|
||||||
* functions for user authentication, new channels and requests.
|
* functions for user authentication, new channels and requests.
|
||||||
*
|
*
|
||||||
|
* Note, that the structure is not copied to the session structure so it needs
|
||||||
|
* to be valid for the whole session lifetime.
|
||||||
|
*
|
||||||
* @code
|
* @code
|
||||||
* struct ssh_server_callbacks_struct cb = {
|
* struct ssh_server_callbacks_struct cb = {
|
||||||
* .userdata = data,
|
* .userdata = data,
|
||||||
@@ -394,7 +399,7 @@ struct ssh_socket_callbacks_struct {
|
|||||||
*/
|
*/
|
||||||
ssh_callback_int_int exception;
|
ssh_callback_int_int exception;
|
||||||
/** This function is called when the ssh_socket_connect was used on the socket
|
/** This function is called when the ssh_socket_connect was used on the socket
|
||||||
* on nonblocking state, and the connection successed.
|
* on nonblocking state, and the connection succeeded.
|
||||||
*/
|
*/
|
||||||
ssh_callback_int_int connected;
|
ssh_callback_int_int connected;
|
||||||
};
|
};
|
||||||
@@ -548,6 +553,9 @@ typedef struct ssh_packet_callbacks_struct *ssh_packet_callbacks;
|
|||||||
* This functions sets the callback structure to use your own callback
|
* This functions sets the callback structure to use your own callback
|
||||||
* functions for auth, logging and status.
|
* functions for auth, logging and status.
|
||||||
*
|
*
|
||||||
|
* Note, that the callback structure is not copied into the session so it needs
|
||||||
|
* to be valid for the whole session lifetime.
|
||||||
|
*
|
||||||
* @code
|
* @code
|
||||||
* struct ssh_callbacks_struct cb = {
|
* struct ssh_callbacks_struct cb = {
|
||||||
* .userdata = data,
|
* .userdata = data,
|
||||||
@@ -619,6 +627,7 @@ typedef void (*ssh_channel_signal_callback) (ssh_session session,
|
|||||||
* @brief SSH channel exit status callback. Called when a channel has received an exit status
|
* @brief SSH channel exit status callback. Called when a channel has received an exit status
|
||||||
* @param session Current session handler
|
* @param session Current session handler
|
||||||
* @param channel the actual channel
|
* @param channel the actual channel
|
||||||
|
* @param exit_status Exit status of the ran command
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
*/
|
*/
|
||||||
typedef void (*ssh_channel_exit_status_callback) (ssh_session session,
|
typedef void (*ssh_channel_exit_status_callback) (ssh_session session,
|
||||||
@@ -631,7 +640,7 @@ typedef void (*ssh_channel_exit_status_callback) (ssh_session session,
|
|||||||
* @param session Current session handler
|
* @param session Current session handler
|
||||||
* @param channel the actual channel
|
* @param channel the actual channel
|
||||||
* @param signal the signal name (without the SIG prefix)
|
* @param signal the signal name (without the SIG prefix)
|
||||||
* @param core a boolean telling wether a core has been dumped or not
|
* @param core a boolean telling whether a core has been dumped or not
|
||||||
* @param errmsg the description of the exception
|
* @param errmsg the description of the exception
|
||||||
* @param lang the language of the description (format: RFC 3066)
|
* @param lang the language of the description (format: RFC 3066)
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
@@ -646,12 +655,13 @@ typedef void (*ssh_channel_exit_signal_callback) (ssh_session session,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SSH channel PTY request from a client.
|
* @brief SSH channel PTY request from a client.
|
||||||
|
* @param session the session
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
* @param term The type of terminal emulation
|
* @param term The type of terminal emulation
|
||||||
* @param width width of the terminal, in characters
|
* @param width width of the terminal, in characters
|
||||||
* @param height height of the terminal, in characters
|
* @param height height of the terminal, in characters
|
||||||
* @param pxwidth width of the terminal, in pixels
|
* @param pxwidth width of the terminal, in pixels
|
||||||
* @param pxheight height of the terminal, in pixels
|
* @param pwheight height of the terminal, in pixels
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
* @returns 0 if the pty request is accepted
|
* @returns 0 if the pty request is accepted
|
||||||
* @returns -1 if the request is denied
|
* @returns -1 if the request is denied
|
||||||
@@ -665,6 +675,7 @@ typedef int (*ssh_channel_pty_request_callback) (ssh_session session,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SSH channel Shell request from a client.
|
* @brief SSH channel Shell request from a client.
|
||||||
|
* @param session the session
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
* @returns 0 if the shell request is accepted
|
* @returns 0 if the shell request is accepted
|
||||||
@@ -677,6 +688,7 @@ typedef int (*ssh_channel_shell_request_callback) (ssh_session session,
|
|||||||
* @brief SSH auth-agent-request from the client. This request is
|
* @brief SSH auth-agent-request from the client. This request is
|
||||||
* sent by a client when agent forwarding is available.
|
* sent by a client when agent forwarding is available.
|
||||||
* Server is free to ignore this callback, no answer is expected.
|
* Server is free to ignore this callback, no answer is expected.
|
||||||
|
* @param session the session
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
*/
|
*/
|
||||||
@@ -688,7 +700,12 @@ typedef void (*ssh_channel_auth_agent_req_callback) (ssh_session session,
|
|||||||
* @brief SSH X11 request from the client. This request is
|
* @brief SSH X11 request from the client. This request is
|
||||||
* sent by a client when X11 forwarding is requested(and available).
|
* sent by a client when X11 forwarding is requested(and available).
|
||||||
* Server is free to ignore this callback, no answer is expected.
|
* Server is free to ignore this callback, no answer is expected.
|
||||||
|
* @param session the session
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
|
* @param single_connection If true, only one channel should be forwarded
|
||||||
|
* @param auth_protocol The X11 authentication method to be used
|
||||||
|
* @param auth_cookie Authentication cookie encoded hexadecimal
|
||||||
|
* @param screen_number Screen number
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
*/
|
*/
|
||||||
typedef void (*ssh_channel_x11_req_callback) (ssh_session session,
|
typedef void (*ssh_channel_x11_req_callback) (ssh_session session,
|
||||||
@@ -700,11 +717,12 @@ typedef void (*ssh_channel_x11_req_callback) (ssh_session session,
|
|||||||
void *userdata);
|
void *userdata);
|
||||||
/**
|
/**
|
||||||
* @brief SSH channel PTY windows change (terminal size) from a client.
|
* @brief SSH channel PTY windows change (terminal size) from a client.
|
||||||
|
* @param session the session
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
* @param width width of the terminal, in characters
|
* @param width width of the terminal, in characters
|
||||||
* @param height height of the terminal, in characters
|
* @param height height of the terminal, in characters
|
||||||
* @param pxwidth width of the terminal, in pixels
|
* @param pxwidth width of the terminal, in pixels
|
||||||
* @param pxheight height of the terminal, in pixels
|
* @param pwheight height of the terminal, in pixels
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
* @returns 0 if the pty request is accepted
|
* @returns 0 if the pty request is accepted
|
||||||
* @returns -1 if the request is denied
|
* @returns -1 if the request is denied
|
||||||
@@ -717,6 +735,7 @@ typedef int (*ssh_channel_pty_window_change_callback) (ssh_session session,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SSH channel Exec request from a client.
|
* @brief SSH channel Exec request from a client.
|
||||||
|
* @param session the session
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
* @param command the shell command to be executed
|
* @param command the shell command to be executed
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
@@ -730,6 +749,7 @@ typedef int (*ssh_channel_exec_request_callback) (ssh_session session,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SSH channel environment request from a client.
|
* @brief SSH channel environment request from a client.
|
||||||
|
* @param session the session
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
* @param env_name name of the environment value to be set
|
* @param env_name name of the environment value to be set
|
||||||
* @param env_value value of the environment value to be set
|
* @param env_value value of the environment value to be set
|
||||||
@@ -746,6 +766,7 @@ typedef int (*ssh_channel_env_request_callback) (ssh_session session,
|
|||||||
void *userdata);
|
void *userdata);
|
||||||
/**
|
/**
|
||||||
* @brief SSH channel subsystem request from a client.
|
* @brief SSH channel subsystem request from a client.
|
||||||
|
* @param session the session
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
* @param subsystem the subsystem required
|
* @param subsystem the subsystem required
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
@@ -760,6 +781,8 @@ typedef int (*ssh_channel_subsystem_request_callback) (ssh_session session,
|
|||||||
/**
|
/**
|
||||||
* @brief SSH channel write will not block (flow control).
|
* @brief SSH channel write will not block (flow control).
|
||||||
*
|
*
|
||||||
|
* @param session the session
|
||||||
|
*
|
||||||
* @param channel the channel
|
* @param channel the channel
|
||||||
*
|
*
|
||||||
* @param[in] bytes size of the remote window in bytes. Writing as much data
|
* @param[in] bytes size of the remote window in bytes. Writing as much data
|
||||||
@@ -771,7 +794,7 @@ typedef int (*ssh_channel_subsystem_request_callback) (ssh_session session,
|
|||||||
*/
|
*/
|
||||||
typedef int (*ssh_channel_write_wontblock_callback) (ssh_session session,
|
typedef int (*ssh_channel_write_wontblock_callback) (ssh_session session,
|
||||||
ssh_channel channel,
|
ssh_channel channel,
|
||||||
size_t bytes,
|
uint32_t bytes,
|
||||||
void *userdata);
|
void *userdata);
|
||||||
|
|
||||||
struct ssh_channel_callbacks_struct {
|
struct ssh_channel_callbacks_struct {
|
||||||
@@ -849,7 +872,11 @@ typedef struct ssh_channel_callbacks_struct *ssh_channel_callbacks;
|
|||||||
* @brief Set the channel callback functions.
|
* @brief Set the channel callback functions.
|
||||||
*
|
*
|
||||||
* This functions sets the callback structure to use your own callback
|
* This functions sets the callback structure to use your own callback
|
||||||
* functions for channel data and exceptions
|
* functions for channel data and exceptions.
|
||||||
|
*
|
||||||
|
* Note, that the structure is not copied to the channel structure so it needs
|
||||||
|
* to be valid as for the whole life of the channel or until it is removed with
|
||||||
|
* ssh_remove_channel_callbacks().
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* struct ssh_channel_callbacks_struct cb = {
|
* struct ssh_channel_callbacks_struct cb = {
|
||||||
@@ -907,7 +934,7 @@ LIBSSH_API int ssh_remove_channel_callbacks(ssh_channel channel,
|
|||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/** @group libssh_threads
|
/** @addtogroup libssh_threads
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -979,7 +1006,7 @@ LIBSSH_API struct ssh_threads_callbacks_struct *ssh_threads_get_noop(void);
|
|||||||
*
|
*
|
||||||
* @param[in] cb The callback to set.
|
* @param[in] cb The callback to set.
|
||||||
*
|
*
|
||||||
* @return 0 on success, < 0 on errror.
|
* @return 0 on success, < 0 on error.
|
||||||
*/
|
*/
|
||||||
LIBSSH_API int ssh_set_log_callback(ssh_logging_callback cb);
|
LIBSSH_API int ssh_set_log_callback(ssh_logging_callback cb);
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,10 @@ struct chacha_ctx {
|
|||||||
#define CHACHA_NONCELEN 8
|
#define CHACHA_NONCELEN 8
|
||||||
#define CHACHA_CTRLEN 8
|
#define CHACHA_CTRLEN 8
|
||||||
#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
|
#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
|
||||||
#define CHACHA_BLOCKLEN 64
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits)
|
void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits)
|
||||||
#ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
|
#ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
|
||||||
@@ -38,4 +41,8 @@ void chacha_encrypt_bytes(struct chacha_ctx *x, const uint8_t *m,
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CHACHA_H */
|
#endif /* CHACHA_H */
|
||||||
|
|||||||
54
include/libssh/chacha20-poly1305-common.h
Normal file
54
include/libssh/chacha20-poly1305-common.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the SSH Library
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 Red Hat, Inc.
|
||||||
|
*
|
||||||
|
* Author: Jakub Jelen <jjelen@redhat.com>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* chacha20-poly1305.h file
|
||||||
|
* This file includes definitions needed for Chacha20-poly1305 AEAD cipher
|
||||||
|
* using different crypto backends.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CHACHA20_POLY1305_H
|
||||||
|
#define CHACHA20_POLY1305_H
|
||||||
|
|
||||||
|
#define CHACHA20_BLOCKSIZE 64
|
||||||
|
#define CHACHA20_KEYLEN 32
|
||||||
|
|
||||||
|
#define POLY1305_TAGLEN 16
|
||||||
|
/* size of the keys k1 and k2 as defined in specs */
|
||||||
|
#define POLY1305_KEYLEN 32
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
#endif
|
||||||
|
struct ssh_packet_header {
|
||||||
|
uint32_t length;
|
||||||
|
uint8_t payload[];
|
||||||
|
}
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
__attribute__ ((packed))
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(pop)
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif /* CHACHA20_POLY1305_H */
|
||||||
@@ -22,6 +22,10 @@
|
|||||||
#define CHANNELS_H_
|
#define CHANNELS_H_
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @internal
|
/** @internal
|
||||||
* Describes the different possible states in a
|
* Describes the different possible states in a
|
||||||
* outgoing (client) channel request
|
* outgoing (client) channel request
|
||||||
@@ -35,7 +39,7 @@ enum ssh_channel_request_state_e {
|
|||||||
SSH_CHANNEL_REQ_STATE_ACCEPTED,
|
SSH_CHANNEL_REQ_STATE_ACCEPTED,
|
||||||
/** A request has been replied and refused */
|
/** A request has been replied and refused */
|
||||||
SSH_CHANNEL_REQ_STATE_DENIED,
|
SSH_CHANNEL_REQ_STATE_DENIED,
|
||||||
/** A request has been replied and an error happend */
|
/** A request has been replied and an error happened */
|
||||||
SSH_CHANNEL_REQ_STATE_ERROR
|
SSH_CHANNEL_REQ_STATE_ERROR
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -97,8 +101,9 @@ SSH_PACKET_CALLBACK(channel_rcv_close);
|
|||||||
SSH_PACKET_CALLBACK(channel_rcv_request);
|
SSH_PACKET_CALLBACK(channel_rcv_request);
|
||||||
SSH_PACKET_CALLBACK(channel_rcv_data);
|
SSH_PACKET_CALLBACK(channel_rcv_data);
|
||||||
|
|
||||||
int channel_default_bufferize(ssh_channel channel, void *data, int len,
|
int channel_default_bufferize(ssh_channel channel,
|
||||||
int is_stderr);
|
void *data, uint32_t len,
|
||||||
|
bool is_stderr);
|
||||||
int ssh_channel_flush(ssh_channel channel);
|
int ssh_channel_flush(ssh_channel channel);
|
||||||
uint32_t ssh_channel_new_id(ssh_session session);
|
uint32_t ssh_channel_new_id(ssh_session session);
|
||||||
ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
|
ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
|
||||||
@@ -108,4 +113,8 @@ int ssh_global_request(ssh_session session,
|
|||||||
ssh_buffer buffer,
|
ssh_buffer buffer,
|
||||||
int reply);
|
int reply);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CHANNELS_H_ */
|
#endif /* CHANNELS_H_ */
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ enum ssh_config_opcode_e {
|
|||||||
SOC_MACS,
|
SOC_MACS,
|
||||||
SOC_COMPRESSION,
|
SOC_COMPRESSION,
|
||||||
SOC_TIMEOUT,
|
SOC_TIMEOUT,
|
||||||
SOC_PROTOCOL,
|
|
||||||
SOC_STRICTHOSTKEYCHECK,
|
SOC_STRICTHOSTKEYCHECK,
|
||||||
SOC_KNOWNHOSTS,
|
SOC_KNOWNHOSTS,
|
||||||
SOC_PROXYCOMMAND,
|
SOC_PROXYCOMMAND,
|
||||||
@@ -60,8 +59,9 @@ enum ssh_config_opcode_e {
|
|||||||
SOC_KBDINTERACTIVEAUTHENTICATION,
|
SOC_KBDINTERACTIVEAUTHENTICATION,
|
||||||
SOC_PASSWORDAUTHENTICATION,
|
SOC_PASSWORDAUTHENTICATION,
|
||||||
SOC_PUBKEYAUTHENTICATION,
|
SOC_PUBKEYAUTHENTICATION,
|
||||||
SOC_PUBKEYACCEPTEDTYPES,
|
SOC_PUBKEYACCEPTEDKEYTYPES,
|
||||||
SOC_REKEYLIMIT,
|
SOC_REKEYLIMIT,
|
||||||
|
SOC_IDENTITYAGENT,
|
||||||
|
|
||||||
SOC_MAX /* Keep this one last in the list */
|
SOC_MAX /* Keep this one last in the list */
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,6 +26,10 @@
|
|||||||
#ifndef CONFIG_PARSER_H_
|
#ifndef CONFIG_PARSER_H_
|
||||||
#define CONFIG_PARSER_H_
|
#define CONFIG_PARSER_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
char *ssh_config_get_cmd(char **str);
|
char *ssh_config_get_cmd(char **str);
|
||||||
|
|
||||||
char *ssh_config_get_token(char **str);
|
char *ssh_config_get_token(char **str);
|
||||||
@@ -54,4 +58,8 @@ int ssh_config_parse_uri(const char *tok,
|
|||||||
char **hostname,
|
char **hostname,
|
||||||
char **port);
|
char **port);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LIBSSH_CONFIG_H_ */
|
#endif /* LIBSSH_CONFIG_H_ */
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ enum ssh_key_exchange_e {
|
|||||||
SSH_KEX_DH_GROUP16_SHA512,
|
SSH_KEX_DH_GROUP16_SHA512,
|
||||||
/* diffie-hellman-group18-sha512 */
|
/* diffie-hellman-group18-sha512 */
|
||||||
SSH_KEX_DH_GROUP18_SHA512,
|
SSH_KEX_DH_GROUP18_SHA512,
|
||||||
|
/* diffie-hellman-group14-sha256 */
|
||||||
|
SSH_KEX_DH_GROUP14_SHA256,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ssh_cipher_e {
|
enum ssh_cipher_e {
|
||||||
@@ -105,11 +107,19 @@ struct ssh_crypto_struct {
|
|||||||
bignum shared_secret;
|
bignum shared_secret;
|
||||||
struct dh_ctx *dh_ctx;
|
struct dh_ctx *dh_ctx;
|
||||||
#ifdef WITH_GEX
|
#ifdef WITH_GEX
|
||||||
size_t dh_pmin; int dh_pn; int dh_pmax; /* preferred group parameters */
|
size_t dh_pmin; size_t dh_pn; size_t dh_pmax; /* preferred group parameters */
|
||||||
#endif /* WITH_GEX */
|
#endif /* WITH_GEX */
|
||||||
#ifdef HAVE_ECDH
|
#ifdef HAVE_ECDH
|
||||||
#ifdef HAVE_OPENSSL_ECC
|
#ifdef HAVE_OPENSSL_ECC
|
||||||
|
/* TODO Change to new API when the OpenSSL will support export of uncompressed EC keys
|
||||||
|
* https://github.com/openssl/openssl/pull/16624
|
||||||
|
* #if OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||||
|
*/
|
||||||
|
#if 1
|
||||||
EC_KEY *ecdh_privkey;
|
EC_KEY *ecdh_privkey;
|
||||||
|
#else
|
||||||
|
EVP_PKEY *ecdh_privkey;
|
||||||
|
#endif /* OPENSSL_VERSION_NUMBER */
|
||||||
#elif defined HAVE_GCRYPT_ECC
|
#elif defined HAVE_GCRYPT_ECC
|
||||||
gcry_sexp_t ecdh_privkey;
|
gcry_sexp_t ecdh_privkey;
|
||||||
#elif defined HAVE_LIBMBEDCRYPTO
|
#elif defined HAVE_LIBMBEDCRYPTO
|
||||||
@@ -124,8 +134,9 @@ struct ssh_crypto_struct {
|
|||||||
ssh_curve25519_pubkey curve25519_server_pubkey;
|
ssh_curve25519_pubkey curve25519_server_pubkey;
|
||||||
#endif
|
#endif
|
||||||
ssh_string dh_server_signature; /* information used by dh_handshake. */
|
ssh_string dh_server_signature; /* information used by dh_handshake. */
|
||||||
size_t digest_len; /* len of the two fields below */
|
size_t session_id_len;
|
||||||
unsigned char *session_id;
|
unsigned char *session_id;
|
||||||
|
size_t digest_len; /* len of the secret hash */
|
||||||
unsigned char *secret_hash; /* Secret hash is same as session id until re-kex */
|
unsigned char *secret_hash; /* Secret hash is same as session id until re-kex */
|
||||||
unsigned char *encryptIV;
|
unsigned char *encryptIV;
|
||||||
unsigned char *decryptIV;
|
unsigned char *decryptIV;
|
||||||
@@ -205,10 +216,23 @@ struct ssh_cipher_struct {
|
|||||||
void (*cleanup)(struct ssh_cipher_struct *cipher);
|
void (*cleanup)(struct ssh_cipher_struct *cipher);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
const struct ssh_cipher_struct *ssh_get_chacha20poly1305_cipher(void);
|
const struct ssh_cipher_struct *ssh_get_chacha20poly1305_cipher(void);
|
||||||
int sshkdf_derive_key(struct ssh_crypto_struct *crypto,
|
int sshkdf_derive_key(struct ssh_crypto_struct *crypto,
|
||||||
unsigned char *key, size_t key_len,
|
unsigned char *key, size_t key_len,
|
||||||
int key_type, unsigned char *output,
|
uint8_t key_type, unsigned char *output,
|
||||||
size_t requested_len);
|
size_t requested_len);
|
||||||
|
|
||||||
|
int secure_memcmp(const void *s1, const void *s2, size_t n);
|
||||||
|
#ifdef HAVE_LIBCRYPTO
|
||||||
|
ENGINE *pki_get_engine(void);
|
||||||
|
#endif /* HAVE_LIBCRYPTO */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _CRYPTO_H_ */
|
#endif /* _CRYPTO_H_ */
|
||||||
|
|||||||
@@ -33,6 +33,10 @@
|
|||||||
#define crypto_scalarmult crypto_scalarmult_curve25519
|
#define crypto_scalarmult crypto_scalarmult_curve25519
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CURVE25519_PUBKEY_SIZE 32
|
#define CURVE25519_PUBKEY_SIZE 32
|
||||||
#define CURVE25519_PRIVKEY_SIZE 32
|
#define CURVE25519_PRIVKEY_SIZE 32
|
||||||
int crypto_scalarmult_base(unsigned char *q, const unsigned char *n);
|
int crypto_scalarmult_base(unsigned char *q, const unsigned char *n);
|
||||||
@@ -48,9 +52,14 @@ typedef unsigned char ssh_curve25519_privkey[CURVE25519_PRIVKEY_SIZE];
|
|||||||
|
|
||||||
|
|
||||||
int ssh_client_curve25519_init(ssh_session session);
|
int ssh_client_curve25519_init(ssh_session session);
|
||||||
|
void ssh_client_curve25519_remove_callbacks(ssh_session session);
|
||||||
|
|
||||||
#ifdef WITH_SERVER
|
#ifdef WITH_SERVER
|
||||||
void ssh_server_curve25519_init(ssh_session session);
|
void ssh_server_curve25519_init(ssh_session session);
|
||||||
#endif /* WITH_SERVER */
|
#endif /* WITH_SERVER */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CURVE25519_H_ */
|
#endif /* CURVE25519_H_ */
|
||||||
|
|||||||
@@ -23,10 +23,19 @@
|
|||||||
#ifndef SRC_DH_GEX_H_
|
#ifndef SRC_DH_GEX_H_
|
||||||
#define SRC_DH_GEX_H_
|
#define SRC_DH_GEX_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
int ssh_client_dhgex_init(ssh_session session);
|
int ssh_client_dhgex_init(ssh_session session);
|
||||||
|
void ssh_client_dhgex_remove_callbacks(ssh_session session);
|
||||||
|
|
||||||
#ifdef WITH_SERVER
|
#ifdef WITH_SERVER
|
||||||
void ssh_server_dhgex_init(ssh_session session);
|
void ssh_server_dhgex_init(ssh_session session);
|
||||||
#endif /* WITH_SERVER */
|
#endif /* WITH_SERVER */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* SRC_DH_GEX_H_ */
|
#endif /* SRC_DH_GEX_H_ */
|
||||||
|
|||||||
@@ -30,20 +30,34 @@ struct dh_ctx;
|
|||||||
#define DH_CLIENT_KEYPAIR 0
|
#define DH_CLIENT_KEYPAIR 0
|
||||||
#define DH_SERVER_KEYPAIR 1
|
#define DH_SERVER_KEYPAIR 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* functions implemented by crypto backends */
|
/* functions implemented by crypto backends */
|
||||||
int ssh_dh_init_common(struct ssh_crypto_struct *crypto);
|
int ssh_dh_init_common(struct ssh_crypto_struct *crypto);
|
||||||
void ssh_dh_cleanup(struct ssh_crypto_struct *crypto);
|
void ssh_dh_cleanup(struct ssh_crypto_struct *crypto);
|
||||||
|
|
||||||
|
#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||||
int ssh_dh_get_parameters(struct dh_ctx *ctx,
|
int ssh_dh_get_parameters(struct dh_ctx *ctx,
|
||||||
const_bignum *modulus, const_bignum *generator);
|
const_bignum *modulus, const_bignum *generator);
|
||||||
|
#else
|
||||||
|
int ssh_dh_get_parameters(struct dh_ctx *ctx,
|
||||||
|
bignum *modulus, bignum *generator);
|
||||||
|
#endif /* OPENSSL_VERSION_NUMBER */
|
||||||
int ssh_dh_set_parameters(struct dh_ctx *ctx,
|
int ssh_dh_set_parameters(struct dh_ctx *ctx,
|
||||||
const bignum modulus, const bignum generator);
|
const bignum modulus, const bignum generator);
|
||||||
|
|
||||||
int ssh_dh_keypair_gen_keys(struct dh_ctx *ctx, int peer);
|
int ssh_dh_keypair_gen_keys(struct dh_ctx *ctx, int peer);
|
||||||
|
#if !defined(HAVE_LIBCRYPTO) || OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||||
int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
|
int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
|
||||||
const_bignum *priv, const_bignum *pub);
|
const_bignum *priv, const_bignum *pub);
|
||||||
|
#else
|
||||||
|
int ssh_dh_keypair_get_keys(struct dh_ctx *ctx, int peer,
|
||||||
|
bignum *priv, bignum *pub);
|
||||||
|
#endif /* OPENSSL_VERSION_NUMBER */
|
||||||
int ssh_dh_keypair_set_keys(struct dh_ctx *ctx, int peer,
|
int ssh_dh_keypair_set_keys(struct dh_ctx *ctx, int peer,
|
||||||
const bignum priv, const bignum pub);
|
bignum priv, bignum pub);
|
||||||
|
|
||||||
int ssh_dh_compute_shared_secret(struct dh_ctx *ctx, int local, int remote,
|
int ssh_dh_compute_shared_secret(struct dh_ctx *ctx, int local, int remote,
|
||||||
bignum *dest);
|
bignum *dest);
|
||||||
@@ -63,8 +77,10 @@ int ssh_dh_get_current_server_publickey_blob(ssh_session session,
|
|||||||
ssh_key ssh_dh_get_next_server_publickey(ssh_session session);
|
ssh_key ssh_dh_get_next_server_publickey(ssh_session session);
|
||||||
int ssh_dh_get_next_server_publickey_blob(ssh_session session,
|
int ssh_dh_get_next_server_publickey_blob(ssh_session session,
|
||||||
ssh_string *pubkey_blob);
|
ssh_string *pubkey_blob);
|
||||||
|
int dh_handshake(ssh_session session);
|
||||||
|
|
||||||
int ssh_client_dh_init(ssh_session session);
|
int ssh_client_dh_init(ssh_session session);
|
||||||
|
void ssh_client_dh_remove_callbacks(ssh_session session);
|
||||||
#ifdef WITH_SERVER
|
#ifdef WITH_SERVER
|
||||||
void ssh_server_dh_init(ssh_session session);
|
void ssh_server_dh_init(ssh_session session);
|
||||||
#endif /* WITH_SERVER */
|
#endif /* WITH_SERVER */
|
||||||
@@ -72,4 +88,8 @@ int ssh_server_dh_process_init(ssh_session session, ssh_buffer packet);
|
|||||||
int ssh_fallback_group(uint32_t pmax, bignum *p, bignum *g);
|
int ssh_fallback_group(uint32_t pmax, bignum *p, bignum *g);
|
||||||
bool ssh_dh_is_known_group(bignum modulus, bignum generator);
|
bool ssh_dh_is_known_group(bignum modulus, bignum generator);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* DH_H_ */
|
#endif /* DH_H_ */
|
||||||
|
|||||||
@@ -42,9 +42,14 @@
|
|||||||
#define HAVE_ECDH 1
|
#define HAVE_ECDH 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
extern struct ssh_packet_callbacks_struct ssh_ecdh_client_callbacks;
|
extern struct ssh_packet_callbacks_struct ssh_ecdh_client_callbacks;
|
||||||
/* Backend-specific functions. */
|
/* Backend-specific functions. */
|
||||||
int ssh_client_ecdh_init(ssh_session session);
|
int ssh_client_ecdh_init(ssh_session session);
|
||||||
|
void ssh_client_ecdh_remove_callbacks(ssh_session session);
|
||||||
int ecdh_build_k(ssh_session session);
|
int ecdh_build_k(ssh_session session);
|
||||||
|
|
||||||
#ifdef WITH_SERVER
|
#ifdef WITH_SERVER
|
||||||
@@ -53,4 +58,8 @@ void ssh_server_ecdh_init(ssh_session session);
|
|||||||
SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init);
|
SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init);
|
||||||
#endif /* WITH_SERVER */
|
#endif /* WITH_SERVER */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ECDH_H_ */
|
#endif /* ECDH_H_ */
|
||||||
|
|||||||
@@ -24,10 +24,10 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup ed25519 ed25519 API
|
* @defgroup ed25519 ed25519 API
|
||||||
* @internal
|
|
||||||
* @brief API for DJB's ed25519
|
* @brief API for DJB's ed25519
|
||||||
*
|
*
|
||||||
* @{ */
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
#define ED25519_PK_LEN 32
|
#define ED25519_PK_LEN 32
|
||||||
#define ED25519_SK_LEN 64
|
#define ED25519_SK_LEN 64
|
||||||
@@ -37,6 +37,10 @@ typedef uint8_t ed25519_pubkey[ED25519_PK_LEN];
|
|||||||
typedef uint8_t ed25519_privkey[ED25519_SK_LEN];
|
typedef uint8_t ed25519_privkey[ED25519_SK_LEN];
|
||||||
typedef uint8_t ed25519_signature[ED25519_SIG_LEN];
|
typedef uint8_t ed25519_signature[ED25519_SIG_LEN];
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/** @internal
|
/** @internal
|
||||||
* @brief generate an ed25519 key pair
|
* @brief generate an ed25519 key pair
|
||||||
* @param[out] pk generated public key
|
* @param[out] pk generated public key
|
||||||
@@ -76,4 +80,8 @@ int crypto_sign_ed25519_open(
|
|||||||
const ed25519_pubkey pk);
|
const ed25519_pubkey pk);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* ED25519_H_ */
|
#endif /* ED25519_H_ */
|
||||||
|
|||||||
@@ -33,13 +33,17 @@ typedef struct {
|
|||||||
uint32_t v[32];
|
uint32_t v[32];
|
||||||
} fe25519;
|
} fe25519;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
void fe25519_freeze(fe25519 *r);
|
void fe25519_freeze(fe25519 *r);
|
||||||
|
|
||||||
void fe25519_unpack(fe25519 *r, const unsigned char x[32]);
|
void fe25519_unpack(fe25519 *r, const unsigned char x[32]);
|
||||||
|
|
||||||
void fe25519_pack(unsigned char r[32], const fe25519 *x);
|
void fe25519_pack(unsigned char r[32], const fe25519 *x);
|
||||||
|
|
||||||
int fe25519_iszero(const fe25519 *x);
|
uint32_t fe25519_iszero(const fe25519 *x);
|
||||||
|
|
||||||
int fe25519_iseq_vartime(const fe25519 *x, const fe25519 *y);
|
int fe25519_iseq_vartime(const fe25519 *x, const fe25519 *y);
|
||||||
|
|
||||||
@@ -65,4 +69,8 @@ void fe25519_invert(fe25519 *r, const fe25519 *x);
|
|||||||
|
|
||||||
void fe25519_pow2523(fe25519 *r, const fe25519 *x);
|
void fe25519_pow2523(fe25519 *r, const fe25519 *x);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ typedef struct
|
|||||||
fe25519 t;
|
fe25519 t;
|
||||||
} ge25519;
|
} ge25519;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
extern const ge25519 ge25519_base;
|
extern const ge25519 ge25519_base;
|
||||||
|
|
||||||
int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]);
|
int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]);
|
||||||
@@ -40,4 +44,8 @@ void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const sc25
|
|||||||
|
|
||||||
void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s);
|
void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -29,6 +29,10 @@
|
|||||||
|
|
||||||
typedef struct ssh_gssapi_struct *ssh_gssapi;
|
typedef struct ssh_gssapi_struct *ssh_gssapi;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_SERVER
|
#ifdef WITH_SERVER
|
||||||
int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n_oid, ssh_string *oids);
|
int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n_oid, ssh_string *oids);
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server);
|
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server);
|
||||||
@@ -42,4 +46,8 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response);
|
|||||||
|
|
||||||
int ssh_gssapi_auth_mic(ssh_session session);
|
int ssh_gssapi_auth_mic(ssh_session session);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* GSSAPI_H */
|
#endif /* GSSAPI_H */
|
||||||
|
|||||||
@@ -31,11 +31,16 @@ struct ssh_kex_struct {
|
|||||||
char *methods[SSH_KEX_METHODS];
|
char *methods[SSH_KEX_METHODS];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_kexinit);
|
SSH_PACKET_CALLBACK(ssh_packet_kexinit);
|
||||||
|
|
||||||
int ssh_send_kex(ssh_session session, int server_kex);
|
int ssh_send_kex(ssh_session session);
|
||||||
void ssh_list_kex(struct ssh_kex_struct *kex);
|
void ssh_list_kex(struct ssh_kex_struct *kex);
|
||||||
int ssh_set_client_kex(ssh_session session);
|
int ssh_set_client_kex(ssh_session session);
|
||||||
|
int ssh_kex_append_extensions(ssh_session session, struct ssh_kex_struct *pkex);
|
||||||
int ssh_kex_select_methods(ssh_session session);
|
int ssh_kex_select_methods(ssh_session session);
|
||||||
int ssh_verify_existing_algo(enum ssh_kex_types_e algo, const char *name);
|
int ssh_verify_existing_algo(enum ssh_kex_types_e algo, const char *name);
|
||||||
char *ssh_keep_known_algos(enum ssh_kex_types_e algo, const char *list);
|
char *ssh_keep_known_algos(enum ssh_kex_types_e algo, const char *list);
|
||||||
@@ -56,4 +61,8 @@ int ssh_hashbufin_add_cookie(ssh_session session, unsigned char *cookie);
|
|||||||
int ssh_hashbufout_add_cookie(ssh_session session);
|
int ssh_hashbufout_add_cookie(ssh_session session);
|
||||||
int ssh_generate_session_keys(ssh_session session);
|
int ssh_generate_session_keys(ssh_session session);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* KEX_H_ */
|
#endif /* KEX_H_ */
|
||||||
|
|||||||
@@ -28,13 +28,17 @@
|
|||||||
struct ssh_public_key_struct {
|
struct ssh_public_key_struct {
|
||||||
int type;
|
int type;
|
||||||
const char *type_c; /* Don't free it ! it is static */
|
const char *type_c; /* Don't free it ! it is static */
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#if defined(HAVE_LIBGCRYPT)
|
||||||
gcry_sexp_t dsa_pub;
|
gcry_sexp_t dsa_pub;
|
||||||
gcry_sexp_t rsa_pub;
|
gcry_sexp_t rsa_pub;
|
||||||
#elif HAVE_LIBCRYPTO
|
#elif defined(HAVE_LIBCRYPTO)
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||||
DSA *dsa_pub;
|
DSA *dsa_pub;
|
||||||
RSA *rsa_pub;
|
RSA *rsa_pub;
|
||||||
#elif HAVE_LIBMBEDCRYPTO
|
#else /* OPENSSL_VERSION_NUMBER */
|
||||||
|
EVP_PKEY *key_pub;
|
||||||
|
#endif
|
||||||
|
#elif defined(HAVE_LIBMBEDCRYPTO)
|
||||||
mbedtls_pk_context *rsa_pub;
|
mbedtls_pk_context *rsa_pub;
|
||||||
void *dsa_pub;
|
void *dsa_pub;
|
||||||
#endif
|
#endif
|
||||||
@@ -42,21 +46,33 @@ struct ssh_public_key_struct {
|
|||||||
|
|
||||||
struct ssh_private_key_struct {
|
struct ssh_private_key_struct {
|
||||||
int type;
|
int type;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#if defined(HAVE_LIBGCRYPT)
|
||||||
gcry_sexp_t dsa_priv;
|
gcry_sexp_t dsa_priv;
|
||||||
gcry_sexp_t rsa_priv;
|
gcry_sexp_t rsa_priv;
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined(HAVE_LIBCRYPTO)
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||||
DSA *dsa_priv;
|
DSA *dsa_priv;
|
||||||
RSA *rsa_priv;
|
RSA *rsa_priv;
|
||||||
#elif HAVE_LIBMBEDCRYPTO
|
#else
|
||||||
|
EVP_PKEY *key_priv;
|
||||||
|
#endif /* OPENSSL_VERSION_NUMBER */
|
||||||
|
#elif defined(HAVE_LIBMBEDCRYPTO)
|
||||||
mbedtls_pk_context *rsa_priv;
|
mbedtls_pk_context *rsa_priv;
|
||||||
void *dsa_priv;
|
void *dsa_priv;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *ssh_type_to_char(int type);
|
const char *ssh_type_to_char(int type);
|
||||||
int ssh_type_from_name(const char *name);
|
int ssh_type_from_name(const char *name);
|
||||||
|
|
||||||
ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s);
|
ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* KEYS_H_ */
|
#endif /* KEYS_H_ */
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
#ifndef SSH_KNOWNHOSTS_H_
|
#ifndef SSH_KNOWNHOSTS_H_
|
||||||
#define SSH_KNOWNHOSTS_H_
|
#define SSH_KNOWNHOSTS_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ssh_list *ssh_known_hosts_get_algorithms(ssh_session session);
|
struct ssh_list *ssh_known_hosts_get_algorithms(ssh_session session);
|
||||||
char *ssh_known_hosts_get_algorithms_names(ssh_session session);
|
char *ssh_known_hosts_get_algorithms_names(ssh_session session);
|
||||||
enum ssh_known_hosts_e
|
enum ssh_known_hosts_e
|
||||||
@@ -29,4 +33,8 @@ ssh_session_get_known_hosts_entry_file(ssh_session session,
|
|||||||
const char *filename,
|
const char *filename,
|
||||||
struct ssh_knownhosts_entry **pentry);
|
struct ssh_knownhosts_entry **pentry);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* SSH_KNOWNHOSTS_H_ */
|
#endif /* SSH_KNOWNHOSTS_H_ */
|
||||||
|
|||||||
@@ -31,6 +31,10 @@
|
|||||||
typedef struct ssh_private_key_struct* ssh_private_key;
|
typedef struct ssh_private_key_struct* ssh_private_key;
|
||||||
typedef struct ssh_public_key_struct* ssh_public_key;
|
typedef struct ssh_public_key_struct* ssh_public_key;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
LIBSSH_API int ssh_auth_list(ssh_session session);
|
LIBSSH_API int ssh_auth_list(ssh_session session);
|
||||||
LIBSSH_API int ssh_userauth_offer_pubkey(ssh_session session, const char *username, int type, ssh_string publickey);
|
LIBSSH_API int ssh_userauth_offer_pubkey(ssh_session session, const char *username, int type, ssh_string publickey);
|
||||||
LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *username, ssh_string publickey, ssh_private_key privatekey);
|
LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *username, ssh_string publickey, ssh_private_key privatekey);
|
||||||
@@ -88,19 +92,19 @@ SSH_DEPRECATED LIBSSH_API int channel_select(ssh_channel *readchans, ssh_channel
|
|||||||
SSH_DEPRECATED LIBSSH_API void channel_set_blocking(ssh_channel channel, int blocking);
|
SSH_DEPRECATED LIBSSH_API void channel_set_blocking(ssh_channel channel, int blocking);
|
||||||
SSH_DEPRECATED LIBSSH_API int channel_write(ssh_channel channel, const void *data, uint32_t len);
|
SSH_DEPRECATED LIBSSH_API int channel_write(ssh_channel channel, const void *data, uint32_t len);
|
||||||
|
|
||||||
LIBSSH_API void privatekey_free(ssh_private_key prv);
|
SSH_DEPRECATED LIBSSH_API void privatekey_free(ssh_private_key prv);
|
||||||
LIBSSH_API ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
|
SSH_DEPRECATED LIBSSH_API ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
|
||||||
int type, const char *passphrase);
|
int type, const char *passphrase);
|
||||||
LIBSSH_API void publickey_free(ssh_public_key key);
|
SSH_DEPRECATED LIBSSH_API void publickey_free(ssh_public_key key);
|
||||||
LIBSSH_API int ssh_publickey_to_file(ssh_session session, const char *file,
|
SSH_DEPRECATED LIBSSH_API int ssh_publickey_to_file(ssh_session session, const char *file,
|
||||||
ssh_string pubkey, int type);
|
ssh_string pubkey, int type);
|
||||||
LIBSSH_API ssh_string publickey_from_file(ssh_session session, const char *filename,
|
SSH_DEPRECATED LIBSSH_API ssh_string publickey_from_file(ssh_session session, const char *filename,
|
||||||
int *type);
|
int *type);
|
||||||
LIBSSH_API ssh_public_key publickey_from_privatekey(ssh_private_key prv);
|
SSH_DEPRECATED LIBSSH_API ssh_public_key publickey_from_privatekey(ssh_private_key prv);
|
||||||
LIBSSH_API ssh_string publickey_to_string(ssh_public_key key);
|
SSH_DEPRECATED LIBSSH_API ssh_string publickey_to_string(ssh_public_key key);
|
||||||
LIBSSH_API int ssh_try_publickey_from_file(ssh_session session, const char *keyfile,
|
SSH_DEPRECATED LIBSSH_API int ssh_try_publickey_from_file(ssh_session session, const char *keyfile,
|
||||||
ssh_string *publickey, int *type);
|
ssh_string *publickey, int *type);
|
||||||
LIBSSH_API enum ssh_keytypes_e ssh_privatekey_type(ssh_private_key privatekey);
|
SSH_DEPRECATED LIBSSH_API enum ssh_keytypes_e ssh_privatekey_type(ssh_private_key privatekey);
|
||||||
|
|
||||||
LIBSSH_API ssh_string ssh_get_pubkey(ssh_session session);
|
LIBSSH_API ssh_string ssh_get_pubkey(ssh_session session);
|
||||||
|
|
||||||
@@ -117,4 +121,8 @@ SSH_DEPRECATED LIBSSH_API size_t string_len(ssh_string str);
|
|||||||
SSH_DEPRECATED LIBSSH_API ssh_string string_new(size_t size);
|
SSH_DEPRECATED LIBSSH_API ssh_string string_new(size_t size);
|
||||||
SSH_DEPRECATED LIBSSH_API char *string_to_char(ssh_string str);
|
SSH_DEPRECATED LIBSSH_API char *string_to_char(ssh_string str);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LEGACY_H_ */
|
#endif /* LEGACY_H_ */
|
||||||
|
|||||||
@@ -38,12 +38,7 @@ typedef EVP_MD_CTX* SHA256CTX;
|
|||||||
typedef EVP_MD_CTX* SHA384CTX;
|
typedef EVP_MD_CTX* SHA384CTX;
|
||||||
typedef EVP_MD_CTX* SHA512CTX;
|
typedef EVP_MD_CTX* SHA512CTX;
|
||||||
typedef EVP_MD_CTX* MD5CTX;
|
typedef EVP_MD_CTX* MD5CTX;
|
||||||
typedef HMAC_CTX* HMACCTX;
|
typedef EVP_MD_CTX* HMACCTX;
|
||||||
#ifdef HAVE_ECC
|
|
||||||
typedef EVP_MD_CTX *EVPCTX;
|
|
||||||
#else
|
|
||||||
typedef void *EVPCTX;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
|
#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
|
||||||
#define SHA256_DIGEST_LEN SHA256_DIGEST_LENGTH
|
#define SHA256_DIGEST_LEN SHA256_DIGEST_LENGTH
|
||||||
@@ -60,10 +55,6 @@ typedef void *EVPCTX;
|
|||||||
|
|
||||||
#include <openssl/bn.h>
|
#include <openssl/bn.h>
|
||||||
#include <openssl/opensslv.h>
|
#include <openssl/opensslv.h>
|
||||||
#define OPENSSL_0_9_7b 0x0090702fL
|
|
||||||
#if (OPENSSL_VERSION_NUMBER <= OPENSSL_0_9_7b)
|
|
||||||
#define BROKEN_AES_CTR
|
|
||||||
#endif
|
|
||||||
typedef BIGNUM* bignum;
|
typedef BIGNUM* bignum;
|
||||||
typedef const BIGNUM* const_bignum;
|
typedef const BIGNUM* const_bignum;
|
||||||
typedef BN_CTX* bignum_CTX;
|
typedef BN_CTX* bignum_CTX;
|
||||||
@@ -96,9 +87,9 @@ typedef BN_CTX* bignum_CTX;
|
|||||||
#define bignum_add(dest, a, b) BN_add(dest, a, b)
|
#define bignum_add(dest, a, b) BN_add(dest, a, b)
|
||||||
#define bignum_sub(dest, a, b) BN_sub(dest, a, b)
|
#define bignum_sub(dest, a, b) BN_sub(dest, a, b)
|
||||||
#define bignum_mod(dest, a, b, ctx) BN_mod(dest, a, b, ctx)
|
#define bignum_mod(dest, a, b, ctx) BN_mod(dest, a, b, ctx)
|
||||||
#define bignum_num_bytes(num) BN_num_bytes(num)
|
#define bignum_num_bytes(num) (size_t)BN_num_bytes(num)
|
||||||
#define bignum_num_bits(num) BN_num_bits(num)
|
#define bignum_num_bits(num) (size_t)BN_num_bits(num)
|
||||||
#define bignum_is_bit_set(num,bit) BN_is_bit_set(num,bit)
|
#define bignum_is_bit_set(num,bit) BN_is_bit_set(num, (int)bit)
|
||||||
#define bignum_bn2bin(num,len, ptr) BN_bn2bin(num, ptr)
|
#define bignum_bn2bin(num,len, ptr) BN_bn2bin(num, ptr)
|
||||||
#define bignum_cmp(num1,num2) BN_cmp(num1,num2)
|
#define bignum_cmp(num1,num2) BN_cmp(num1,num2)
|
||||||
#define bignum_rshift1(dest, src) BN_rshift1(dest, src)
|
#define bignum_rshift1(dest, src) BN_rshift1(dest, src)
|
||||||
@@ -114,6 +105,8 @@ typedef BN_CTX* bignum_CTX;
|
|||||||
/* Returns true if the OpenSSL is operating in FIPS mode */
|
/* Returns true if the OpenSSL is operating in FIPS mode */
|
||||||
#ifdef HAVE_OPENSSL_FIPS_MODE
|
#ifdef HAVE_OPENSSL_FIPS_MODE
|
||||||
#define ssh_fips_mode() (FIPS_mode() != 0)
|
#define ssh_fips_mode() (FIPS_mode() != 0)
|
||||||
|
#elif OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||||
|
#define ssh_fips_mode() EVP_default_properties_is_fips_enabled(NULL)
|
||||||
#else
|
#else
|
||||||
#define ssh_fips_mode() false
|
#define ssh_fips_mode() false
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ typedef gcry_md_hd_t SHA384CTX;
|
|||||||
typedef gcry_md_hd_t SHA512CTX;
|
typedef gcry_md_hd_t SHA512CTX;
|
||||||
typedef gcry_md_hd_t MD5CTX;
|
typedef gcry_md_hd_t MD5CTX;
|
||||||
typedef gcry_md_hd_t HMACCTX;
|
typedef gcry_md_hd_t HMACCTX;
|
||||||
typedef gcry_md_hd_t EVPCTX;
|
|
||||||
#define SHA_DIGEST_LENGTH 20
|
#define SHA_DIGEST_LENGTH 20
|
||||||
#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
|
#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
|
||||||
#define MD5_DIGEST_LEN 16
|
#define MD5_DIGEST_LEN 16
|
||||||
@@ -104,6 +103,10 @@ int ssh_gcry_rand_range(bignum rnd, bignum max);
|
|||||||
} while(0)
|
} while(0)
|
||||||
/* Helper functions for data conversions. */
|
/* Helper functions for data conversions. */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Extract an MPI from the given s-expression SEXP named NAME which is
|
/* Extract an MPI from the given s-expression SEXP named NAME which is
|
||||||
encoded using INFORMAT and store it in a newly allocated ssh_string
|
encoded using INFORMAT and store it in a newly allocated ssh_string
|
||||||
encoded using OUTFORMAT. */
|
encoded using OUTFORMAT. */
|
||||||
@@ -114,6 +117,10 @@ ssh_string ssh_sexp_extract_mpi(const gcry_sexp_t sexp,
|
|||||||
|
|
||||||
#define ssh_fips_mode() false
|
#define ssh_fips_mode() false
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* HAVE_LIBGCRYPT */
|
#endif /* HAVE_LIBGCRYPT */
|
||||||
|
|
||||||
#endif /* LIBGCRYPT_H_ */
|
#endif /* LIBGCRYPT_H_ */
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ typedef mbedtls_md_context_t *SHA384CTX;
|
|||||||
typedef mbedtls_md_context_t *SHA512CTX;
|
typedef mbedtls_md_context_t *SHA512CTX;
|
||||||
typedef mbedtls_md_context_t *MD5CTX;
|
typedef mbedtls_md_context_t *MD5CTX;
|
||||||
typedef mbedtls_md_context_t *HMACCTX;
|
typedef mbedtls_md_context_t *HMACCTX;
|
||||||
typedef mbedtls_md_context_t *EVPCTX;
|
|
||||||
|
|
||||||
#define SHA_DIGEST_LENGTH 20
|
#define SHA_DIGEST_LENGTH 20
|
||||||
#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
|
#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH
|
||||||
@@ -73,6 +72,10 @@ struct mbedtls_ecdsa_sig {
|
|||||||
bignum s;
|
bignum s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
bignum ssh_mbedcry_bn_new(void);
|
bignum ssh_mbedcry_bn_new(void);
|
||||||
void ssh_mbedcry_bn_free(bignum num);
|
void ssh_mbedcry_bn_free(bignum num);
|
||||||
unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix);
|
unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix);
|
||||||
@@ -136,5 +139,9 @@ ssh_string make_ecpoint_string(const mbedtls_ecp_group *g, const
|
|||||||
|
|
||||||
#define ssh_fips_mode() false
|
#define ssh_fips_mode() false
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* HAVE_LIBMBEDCRYPTO */
|
#endif /* HAVE_LIBMBEDCRYPTO */
|
||||||
#endif /* LIBMBEDCRYPTO_H_ */
|
#endif /* LIBMBEDCRYPTO_H_ */
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of the SSH Library
|
* This file is part of the SSH Library
|
||||||
*
|
*
|
||||||
* Copyright (c) 2003-2009 by Aris Adamantiadis
|
* Copyright (c) 2003-2023 by Aris Adamantiadis and the libssh team
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef _LIBSSH_H
|
#ifndef _LIBSSH_H
|
||||||
#define _LIBSSH_H
|
#define _LIBSSH_H
|
||||||
|
|
||||||
|
#include <libssh/libssh_version.h>
|
||||||
|
|
||||||
#if defined _WIN32 || defined __CYGWIN__
|
#if defined _WIN32 || defined __CYGWIN__
|
||||||
#ifdef LIBSSH_STATIC
|
#ifdef LIBSSH_STATIC
|
||||||
#define LIBSSH_API
|
#define LIBSSH_API
|
||||||
@@ -47,6 +49,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
/* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
|
/* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
|
||||||
typedef int int32_t;
|
typedef int int32_t;
|
||||||
@@ -71,23 +75,6 @@
|
|||||||
#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
|
#define SSH_STRINGIFY(s) SSH_TOSTRING(s)
|
||||||
#define SSH_TOSTRING(s) #s
|
#define SSH_TOSTRING(s) #s
|
||||||
|
|
||||||
/* libssh version macros */
|
|
||||||
#define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
|
|
||||||
#define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c
|
|
||||||
#define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c)
|
|
||||||
|
|
||||||
/* libssh version */
|
|
||||||
#define LIBSSH_VERSION_MAJOR 0
|
|
||||||
#define LIBSSH_VERSION_MINOR 9
|
|
||||||
#define LIBSSH_VERSION_MICRO 2
|
|
||||||
|
|
||||||
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
|
|
||||||
LIBSSH_VERSION_MINOR, \
|
|
||||||
LIBSSH_VERSION_MICRO)
|
|
||||||
#define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \
|
|
||||||
LIBSSH_VERSION_MINOR, \
|
|
||||||
LIBSSH_VERSION_MICRO)
|
|
||||||
|
|
||||||
/* GCC have printf type attribute check. */
|
/* GCC have printf type attribute check. */
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
|
#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
|
||||||
@@ -95,7 +82,7 @@
|
|||||||
#define PRINTF_ATTRIBUTE(a,b)
|
#define PRINTF_ATTRIBUTE(a,b)
|
||||||
#endif /* __GNUC__ */
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#if !defined(SSH_SUPPRESS_DEPRECATED) && defined(__GNUC__)
|
||||||
#define SSH_DEPRECATED __attribute__ ((deprecated))
|
#define SSH_DEPRECATED __attribute__ ((deprecated))
|
||||||
#else
|
#else
|
||||||
#define SSH_DEPRECATED
|
#define SSH_DEPRECATED
|
||||||
@@ -168,13 +155,13 @@ enum ssh_auth_e {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* auth flags */
|
/* auth flags */
|
||||||
#define SSH_AUTH_METHOD_UNKNOWN 0
|
#define SSH_AUTH_METHOD_UNKNOWN 0x0000u
|
||||||
#define SSH_AUTH_METHOD_NONE 0x0001
|
#define SSH_AUTH_METHOD_NONE 0x0001u
|
||||||
#define SSH_AUTH_METHOD_PASSWORD 0x0002
|
#define SSH_AUTH_METHOD_PASSWORD 0x0002u
|
||||||
#define SSH_AUTH_METHOD_PUBLICKEY 0x0004
|
#define SSH_AUTH_METHOD_PUBLICKEY 0x0004u
|
||||||
#define SSH_AUTH_METHOD_HOSTBASED 0x0008
|
#define SSH_AUTH_METHOD_HOSTBASED 0x0008u
|
||||||
#define SSH_AUTH_METHOD_INTERACTIVE 0x0010
|
#define SSH_AUTH_METHOD_INTERACTIVE 0x0010u
|
||||||
#define SSH_AUTH_METHOD_GSSAPI_MIC 0x0020
|
#define SSH_AUTH_METHOD_GSSAPI_MIC 0x0020u
|
||||||
|
|
||||||
/* messages */
|
/* messages */
|
||||||
enum ssh_requests_e {
|
enum ssh_requests_e {
|
||||||
@@ -304,6 +291,10 @@ enum ssh_keytypes_e{
|
|||||||
SSH_KEYTYPE_ECDSA_P384_CERT01,
|
SSH_KEYTYPE_ECDSA_P384_CERT01,
|
||||||
SSH_KEYTYPE_ECDSA_P521_CERT01,
|
SSH_KEYTYPE_ECDSA_P521_CERT01,
|
||||||
SSH_KEYTYPE_ED25519_CERT01,
|
SSH_KEYTYPE_ED25519_CERT01,
|
||||||
|
SSH_KEYTYPE_SK_ECDSA,
|
||||||
|
SSH_KEYTYPE_SK_ECDSA_CERT01,
|
||||||
|
SSH_KEYTYPE_SK_ED25519,
|
||||||
|
SSH_KEYTYPE_SK_ED25519_CERT01,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ssh_keycmp_e {
|
enum ssh_keycmp_e {
|
||||||
@@ -366,7 +357,7 @@ enum {
|
|||||||
#define SSH_LOG_WARN 1
|
#define SSH_LOG_WARN 1
|
||||||
/** Get some information what's going on */
|
/** Get some information what's going on */
|
||||||
#define SSH_LOG_INFO 2
|
#define SSH_LOG_INFO 2
|
||||||
/** Get detailed debuging information **/
|
/** Get detailed debugging information **/
|
||||||
#define SSH_LOG_DEBUG 3
|
#define SSH_LOG_DEBUG 3
|
||||||
/** Get trace output, packet information, ... */
|
/** Get trace output, packet information, ... */
|
||||||
#define SSH_LOG_TRACE 4
|
#define SSH_LOG_TRACE 4
|
||||||
@@ -415,6 +406,8 @@ enum ssh_options_e {
|
|||||||
SSH_OPTIONS_PROCESS_CONFIG,
|
SSH_OPTIONS_PROCESS_CONFIG,
|
||||||
SSH_OPTIONS_REKEY_DATA,
|
SSH_OPTIONS_REKEY_DATA,
|
||||||
SSH_OPTIONS_REKEY_TIME,
|
SSH_OPTIONS_REKEY_TIME,
|
||||||
|
SSH_OPTIONS_RSA_MIN_SIZE,
|
||||||
|
SSH_OPTIONS_IDENTITY_AGENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -486,8 +479,6 @@ LIBSSH_API int ssh_channel_request_x11(ssh_channel channel, int single_connectio
|
|||||||
const char *cookie, int screen_number);
|
const char *cookie, int screen_number);
|
||||||
LIBSSH_API int ssh_channel_request_auth_agent(ssh_channel channel);
|
LIBSSH_API int ssh_channel_request_auth_agent(ssh_channel channel);
|
||||||
LIBSSH_API int ssh_channel_send_eof(ssh_channel channel);
|
LIBSSH_API int ssh_channel_send_eof(ssh_channel channel);
|
||||||
LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
|
|
||||||
timeval * timeout);
|
|
||||||
LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking);
|
LIBSSH_API void ssh_channel_set_blocking(ssh_channel channel, int blocking);
|
||||||
LIBSSH_API void ssh_channel_set_counter(ssh_channel channel,
|
LIBSSH_API void ssh_channel_set_counter(ssh_channel channel,
|
||||||
ssh_counter counter);
|
ssh_counter counter);
|
||||||
@@ -518,7 +509,12 @@ LIBSSH_API char *ssh_dirname (const char *path);
|
|||||||
LIBSSH_API int ssh_finalize(void);
|
LIBSSH_API int ssh_finalize(void);
|
||||||
|
|
||||||
/* REVERSE PORT FORWARDING */
|
/* REVERSE PORT FORWARDING */
|
||||||
LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session,
|
LIBSSH_API ssh_channel ssh_channel_open_forward_port(ssh_session session,
|
||||||
|
int timeout_ms,
|
||||||
|
int *destination_port,
|
||||||
|
char **originator,
|
||||||
|
int *originator_port);
|
||||||
|
SSH_DEPRECATED LIBSSH_API ssh_channel ssh_channel_accept_forward(ssh_session session,
|
||||||
int timeout_ms,
|
int timeout_ms,
|
||||||
int *destination_port);
|
int *destination_port);
|
||||||
LIBSSH_API int ssh_channel_cancel_forward(ssh_session session,
|
LIBSSH_API int ssh_channel_cancel_forward(ssh_session session,
|
||||||
@@ -560,7 +556,27 @@ SSH_DEPRECATED LIBSSH_API int ssh_write_knownhost(ssh_session session);
|
|||||||
SSH_DEPRECATED LIBSSH_API char *ssh_dump_knownhost(ssh_session session);
|
SSH_DEPRECATED LIBSSH_API char *ssh_dump_knownhost(ssh_session session);
|
||||||
SSH_DEPRECATED LIBSSH_API int ssh_is_server_known(ssh_session session);
|
SSH_DEPRECATED LIBSSH_API int ssh_is_server_known(ssh_session session);
|
||||||
SSH_DEPRECATED LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
|
SSH_DEPRECATED LIBSSH_API void ssh_print_hexa(const char *descr, const unsigned char *what, size_t len);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_channel_select(ssh_channel *readchans, ssh_channel *writechans, ssh_channel *exceptchans, struct
|
||||||
|
timeval * timeout);
|
||||||
|
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_close(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason);
|
||||||
|
SSH_DEPRECATED LIBSSH_API void ssh_scp_free(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_init(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_pull_request(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size);
|
||||||
|
SSH_DEPRECATED LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
|
||||||
|
|
||||||
|
|
||||||
LIBSSH_API int ssh_get_random(void *where,int len,int strong);
|
LIBSSH_API int ssh_get_random(void *where,int len,int strong);
|
||||||
@@ -598,6 +614,10 @@ LIBSSH_API int ssh_set_log_level(int level);
|
|||||||
LIBSSH_API int ssh_get_log_level(void);
|
LIBSSH_API int ssh_get_log_level(void);
|
||||||
LIBSSH_API void *ssh_get_log_userdata(void);
|
LIBSSH_API void *ssh_get_log_userdata(void);
|
||||||
LIBSSH_API int ssh_set_log_userdata(void *data);
|
LIBSSH_API int ssh_set_log_userdata(void *data);
|
||||||
|
LIBSSH_API void ssh_vlog(int verbosity,
|
||||||
|
const char *function,
|
||||||
|
const char *format,
|
||||||
|
va_list *va) PRINTF_ATTRIBUTE(3, 0);
|
||||||
LIBSSH_API void _ssh_log(int verbosity,
|
LIBSSH_API void _ssh_log(int verbosity,
|
||||||
const char *function,
|
const char *function,
|
||||||
const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
|
const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
|
||||||
@@ -633,7 +653,13 @@ LIBSSH_API ssh_pcap_file ssh_pcap_file_new(void);
|
|||||||
LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename);
|
LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SSH authentication callback.
|
* @addtogroup libssh_auth
|
||||||
|
*
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SSH authentication callback for password and publickey auth.
|
||||||
*
|
*
|
||||||
* @param prompt Prompt to be displayed.
|
* @param prompt Prompt to be displayed.
|
||||||
* @param buf Buffer to save the password. You should null-terminate it.
|
* @param buf Buffer to save the password. You should null-terminate it.
|
||||||
@@ -648,6 +674,8 @@ LIBSSH_API int ssh_pcap_file_open(ssh_pcap_file pcap, const char *filename);
|
|||||||
typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
|
typedef int (*ssh_auth_callback) (const char *prompt, char *buf, size_t len,
|
||||||
int echo, int verify, void *userdata);
|
int echo, int verify, void *userdata);
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
LIBSSH_API ssh_key ssh_key_new(void);
|
LIBSSH_API ssh_key ssh_key_new(void);
|
||||||
#define SSH_KEY_FREE(x) \
|
#define SSH_KEY_FREE(x) \
|
||||||
do { if ((x) != NULL) { ssh_key_free(x); x = NULL; } } while(0)
|
do { if ((x) != NULL) { ssh_key_free(x); x = NULL; } } while(0)
|
||||||
@@ -660,6 +688,7 @@ LIBSSH_API int ssh_key_is_private(const ssh_key k);
|
|||||||
LIBSSH_API int ssh_key_cmp(const ssh_key k1,
|
LIBSSH_API int ssh_key_cmp(const ssh_key k1,
|
||||||
const ssh_key k2,
|
const ssh_key k2,
|
||||||
enum ssh_keycmp_e what);
|
enum ssh_keycmp_e what);
|
||||||
|
LIBSSH_API ssh_key ssh_key_dup(const ssh_key key);
|
||||||
|
|
||||||
LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter,
|
LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter,
|
||||||
ssh_key *pkey);
|
ssh_key *pkey);
|
||||||
@@ -715,24 +744,6 @@ LIBSSH_API void ssh_print_hash(enum ssh_publickey_hash_type type, unsigned char
|
|||||||
LIBSSH_API int ssh_send_ignore (ssh_session session, const char *data);
|
LIBSSH_API int ssh_send_ignore (ssh_session session, const char *data);
|
||||||
LIBSSH_API int ssh_send_debug (ssh_session session, const char *message, int always_display);
|
LIBSSH_API int ssh_send_debug (ssh_session session, const char *message, int always_display);
|
||||||
LIBSSH_API void ssh_gssapi_set_creds(ssh_session session, const ssh_gssapi_creds creds);
|
LIBSSH_API void ssh_gssapi_set_creds(ssh_session session, const ssh_gssapi_creds creds);
|
||||||
LIBSSH_API int ssh_scp_accept_request(ssh_scp scp);
|
|
||||||
LIBSSH_API int ssh_scp_close(ssh_scp scp);
|
|
||||||
LIBSSH_API int ssh_scp_deny_request(ssh_scp scp, const char *reason);
|
|
||||||
LIBSSH_API void ssh_scp_free(ssh_scp scp);
|
|
||||||
LIBSSH_API int ssh_scp_init(ssh_scp scp);
|
|
||||||
LIBSSH_API int ssh_scp_leave_directory(ssh_scp scp);
|
|
||||||
LIBSSH_API ssh_scp ssh_scp_new(ssh_session session, int mode, const char *location);
|
|
||||||
LIBSSH_API int ssh_scp_pull_request(ssh_scp scp);
|
|
||||||
LIBSSH_API int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode);
|
|
||||||
LIBSSH_API int ssh_scp_push_file(ssh_scp scp, const char *filename, size_t size, int perms);
|
|
||||||
LIBSSH_API int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int perms);
|
|
||||||
LIBSSH_API int ssh_scp_read(ssh_scp scp, void *buffer, size_t size);
|
|
||||||
LIBSSH_API const char *ssh_scp_request_get_filename(ssh_scp scp);
|
|
||||||
LIBSSH_API int ssh_scp_request_get_permissions(ssh_scp scp);
|
|
||||||
LIBSSH_API size_t ssh_scp_request_get_size(ssh_scp scp);
|
|
||||||
LIBSSH_API uint64_t ssh_scp_request_get_size64(ssh_scp scp);
|
|
||||||
LIBSSH_API const char *ssh_scp_request_get_warning(ssh_scp scp);
|
|
||||||
LIBSSH_API int ssh_scp_write(ssh_scp scp, const void *buffer, size_t len);
|
|
||||||
LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
|
LIBSSH_API int ssh_select(ssh_channel *channels, ssh_channel *outchannels, socket_t maxfd,
|
||||||
fd_set *readfds, struct timeval *timeout);
|
fd_set *readfds, struct timeval *timeout);
|
||||||
LIBSSH_API int ssh_service_request(ssh_session session, const char *service);
|
LIBSSH_API int ssh_service_request(ssh_session session, const char *service);
|
||||||
@@ -760,6 +771,8 @@ LIBSSH_API int ssh_userauth_publickey(ssh_session session,
|
|||||||
LIBSSH_API int ssh_userauth_agent(ssh_session session,
|
LIBSSH_API int ssh_userauth_agent(ssh_session session,
|
||||||
const char *username);
|
const char *username);
|
||||||
#endif
|
#endif
|
||||||
|
LIBSSH_API int ssh_userauth_publickey_auto_get_current_identity(ssh_session session,
|
||||||
|
char** value);
|
||||||
LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
|
LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
|
||||||
const char *username,
|
const char *username,
|
||||||
const char *passphrase);
|
const char *passphrase);
|
||||||
@@ -828,6 +841,7 @@ LIBSSH_API int ssh_buffer_add_data(ssh_buffer buffer, const void *data, uint32_t
|
|||||||
LIBSSH_API uint32_t ssh_buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen);
|
LIBSSH_API uint32_t ssh_buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen);
|
||||||
LIBSSH_API void *ssh_buffer_get(ssh_buffer buffer);
|
LIBSSH_API void *ssh_buffer_get(ssh_buffer buffer);
|
||||||
LIBSSH_API uint32_t ssh_buffer_get_len(ssh_buffer buffer);
|
LIBSSH_API uint32_t ssh_buffer_get_len(ssh_buffer buffer);
|
||||||
|
LIBSSH_API int ssh_session_set_disconnect_message(ssh_session session, const char *message);
|
||||||
|
|
||||||
#ifndef LIBSSH_LEGACY_0_4
|
#ifndef LIBSSH_LEGACY_0_4
|
||||||
#include "libssh/legacy.h"
|
#include "libssh/legacy.h"
|
||||||
|
|||||||
41
include/libssh/libssh_version.h.cmake
Normal file
41
include/libssh/libssh_version.h.cmake
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the SSH Library
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 by Heiko Thiery
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBSSH_VERSION_H
|
||||||
|
#define _LIBSSH_VERSION_H
|
||||||
|
|
||||||
|
/* libssh version macros */
|
||||||
|
#define SSH_VERSION_INT(a, b, c) ((a) << 16 | (b) << 8 | (c))
|
||||||
|
#define SSH_VERSION_DOT(a, b, c) a ##.## b ##.## c
|
||||||
|
#define SSH_VERSION(a, b, c) SSH_VERSION_DOT(a, b, c)
|
||||||
|
|
||||||
|
/* libssh version */
|
||||||
|
#define LIBSSH_VERSION_MAJOR @libssh_VERSION_MAJOR@
|
||||||
|
#define LIBSSH_VERSION_MINOR @libssh_VERSION_MINOR@
|
||||||
|
#define LIBSSH_VERSION_MICRO @libssh_VERSION_PATCH@
|
||||||
|
|
||||||
|
#define LIBSSH_VERSION_INT SSH_VERSION_INT(LIBSSH_VERSION_MAJOR, \
|
||||||
|
LIBSSH_VERSION_MINOR, \
|
||||||
|
LIBSSH_VERSION_MICRO)
|
||||||
|
#define LIBSSH_VERSION SSH_VERSION(LIBSSH_VERSION_MAJOR, \
|
||||||
|
LIBSSH_VERSION_MINOR, \
|
||||||
|
LIBSSH_VERSION_MICRO)
|
||||||
|
|
||||||
|
#endif /* _LIBSSH_VERSION_H */
|
||||||
@@ -369,13 +369,11 @@ public:
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
void log(int priority, const char *format, ...){
|
void log(int priority, const char *format, ...){
|
||||||
char buffer[1024];
|
|
||||||
va_list va;
|
va_list va;
|
||||||
|
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
vsnprintf(buffer, sizeof(buffer), format, va);
|
ssh_vlog(priority, "libsshpp", format, &va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
_ssh_log(priority, "libsshpp", "%s", buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief copies options from a session to another
|
/** @brief copies options from a session to another
|
||||||
@@ -525,7 +523,7 @@ public:
|
|||||||
return ssh_channel_is_open(channel) != 0;
|
return ssh_channel_is_open(channel) != 0;
|
||||||
}
|
}
|
||||||
int openForward(const char *remotehost, int remoteport,
|
int openForward(const char *remotehost, int remoteport,
|
||||||
const char *sourcehost=NULL, int localport=0){
|
const char *sourcehost, int localport=0){
|
||||||
int err=ssh_channel_open_forward(channel,remotehost,remoteport,
|
int err=ssh_channel_open_forward(channel,remotehost,remoteport,
|
||||||
sourcehost, localport);
|
sourcehost, localport);
|
||||||
ssh_throw(err);
|
ssh_throw(err);
|
||||||
@@ -632,8 +630,8 @@ public:
|
|||||||
* @param is_stderr write should be done on the stderr channel (server only)
|
* @param is_stderr write should be done on the stderr channel (server only)
|
||||||
* @returns number of bytes written
|
* @returns number of bytes written
|
||||||
* @throws SshException in case of error
|
* @throws SshException in case of error
|
||||||
* @see channel_write
|
* @see ssh_channel_write
|
||||||
* @see channel_write_stderr
|
* @see ssh_channel_write_stderr
|
||||||
*/
|
*/
|
||||||
int write(const void *data, size_t len, bool is_stderr=false){
|
int write(const void *data, size_t len, bool is_stderr=false){
|
||||||
int ret;
|
int ret;
|
||||||
@@ -671,7 +669,7 @@ private:
|
|||||||
|
|
||||||
inline Channel *Session::acceptForward(int timeout_ms){
|
inline Channel *Session::acceptForward(int timeout_ms){
|
||||||
ssh_channel forward =
|
ssh_channel forward =
|
||||||
ssh_channel_accept_forward(c_session, timeout_ms, NULL);
|
ssh_channel_open_forward_port(c_session, timeout_ms, NULL, NULL, NULL);
|
||||||
ssh_throw_null(c_session,forward);
|
ssh_throw_null(c_session,forward);
|
||||||
Channel *newchan = new Channel(*this,forward);
|
Channel *newchan = new Channel(*this,forward);
|
||||||
return newchan;
|
return newchan;
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ struct ssh_auth_request {
|
|||||||
int method;
|
int method;
|
||||||
char *password;
|
char *password;
|
||||||
struct ssh_key_struct *pubkey;
|
struct ssh_key_struct *pubkey;
|
||||||
char signature_state;
|
char *sigtype;
|
||||||
|
enum ssh_publickey_state_e signature_state;
|
||||||
char kbdint_response;
|
char kbdint_response;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,6 +92,10 @@ struct ssh_message_struct {
|
|||||||
struct ssh_global_request global_request;
|
struct ssh_global_request global_request;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_channel_open);
|
SSH_PACKET_CALLBACK(ssh_packet_channel_open);
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_global_request);
|
SSH_PACKET_CALLBACK(ssh_packet_global_request);
|
||||||
|
|
||||||
@@ -103,4 +108,8 @@ int ssh_message_handle_channel_request(ssh_session session, ssh_channel channel,
|
|||||||
const char *request, uint8_t want_reply);
|
const char *request, uint8_t want_reply);
|
||||||
ssh_message ssh_message_pop_head(ssh_session session);
|
ssh_message ssh_message_pop_head(ssh_session session);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* MESSAGES_H_ */
|
#endif /* MESSAGES_H_ */
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
#ifndef MISC_H_
|
#ifndef MISC_H_
|
||||||
#define MISC_H_
|
#define MISC_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* in misc.c */
|
/* in misc.c */
|
||||||
/* gets the user home dir. */
|
/* gets the user home dir. */
|
||||||
char *ssh_get_user_home_dir(void);
|
char *ssh_get_user_home_dir(void);
|
||||||
@@ -51,6 +55,12 @@ struct ssh_timestamp {
|
|||||||
long useconds;
|
long useconds;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ssh_quote_state_e {
|
||||||
|
NO_QUOTE,
|
||||||
|
SINGLE_QUOTE,
|
||||||
|
DOUBLE_QUOTE
|
||||||
|
};
|
||||||
|
|
||||||
struct ssh_list *ssh_list_new(void);
|
struct ssh_list *ssh_list_new(void);
|
||||||
void ssh_list_free(struct ssh_list *list);
|
void ssh_list_free(struct ssh_list *list);
|
||||||
struct ssh_iterator *ssh_list_get_iterator(const struct ssh_list *list);
|
struct ssh_iterator *ssh_list_get_iterator(const struct ssh_list *list);
|
||||||
@@ -69,13 +79,13 @@ const void *_ssh_list_pop_head(struct ssh_list *list);
|
|||||||
|
|
||||||
/** @brief fetch the head element of a list and remove it from list
|
/** @brief fetch the head element of a list and remove it from list
|
||||||
* @param type type of the element to return
|
* @param type type of the element to return
|
||||||
* @param list the ssh_list to use
|
* @param ssh_list the ssh_list to use
|
||||||
* @return the first element of the list, or NULL if the list is empty
|
* @return the first element of the list, or NULL if the list is empty
|
||||||
*/
|
*/
|
||||||
#define ssh_list_pop_head(type, ssh_list)\
|
#define ssh_list_pop_head(type, ssh_list)\
|
||||||
((type)_ssh_list_pop_head(ssh_list))
|
((type)_ssh_list_pop_head(ssh_list))
|
||||||
|
|
||||||
int ssh_make_milliseconds(long sec, long usec);
|
int ssh_make_milliseconds(unsigned long sec, unsigned long usec);
|
||||||
void ssh_timestamp_init(struct ssh_timestamp *ts);
|
void ssh_timestamp_init(struct ssh_timestamp *ts);
|
||||||
int ssh_timeout_elapsed(struct ssh_timestamp *ts, int timeout);
|
int ssh_timeout_elapsed(struct ssh_timestamp *ts, int timeout);
|
||||||
int ssh_timeout_update(struct ssh_timestamp *ts, int timeout);
|
int ssh_timeout_update(struct ssh_timestamp *ts, int timeout);
|
||||||
@@ -88,4 +98,16 @@ void ssh_log_hexdump(const char *descr, const unsigned char *what, size_t len);
|
|||||||
|
|
||||||
int ssh_mkdirs(const char *pathname, mode_t mode);
|
int ssh_mkdirs(const char *pathname, mode_t mode);
|
||||||
|
|
||||||
|
int ssh_quote_file_name(const char *file_name, char *buf, size_t buf_len);
|
||||||
|
int ssh_newline_vis(const char *string, char *buf, size_t buf_len);
|
||||||
|
int ssh_tmpname(char *name);
|
||||||
|
|
||||||
|
char *ssh_strreplace(const char *src, const char *pattern, const char *repl);
|
||||||
|
|
||||||
|
int ssh_check_hostname_syntax(const char *hostname);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* MISC_H_ */
|
#endif /* MISC_H_ */
|
||||||
|
|||||||
@@ -21,10 +21,19 @@
|
|||||||
#ifndef _OPTIONS_H
|
#ifndef _OPTIONS_H
|
||||||
#define _OPTIONS_H
|
#define _OPTIONS_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
int ssh_config_parse_file(ssh_session session, const char *filename);
|
int ssh_config_parse_file(ssh_session session, const char *filename);
|
||||||
|
int ssh_config_parse_string(ssh_session session, const char *input);
|
||||||
int ssh_options_set_algo(ssh_session session,
|
int ssh_options_set_algo(ssh_session session,
|
||||||
enum ssh_kex_types_e algo,
|
enum ssh_kex_types_e algo,
|
||||||
const char *list);
|
const char *list);
|
||||||
int ssh_options_apply(ssh_session session);
|
int ssh_options_apply(ssh_session session);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _OPTIONS_H */
|
#endif /* _OPTIONS_H */
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ enum ssh_packet_filter_result_e {
|
|||||||
|
|
||||||
int ssh_packet_send(ssh_session session);
|
int ssh_packet_send(ssh_session session);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_unimplemented);
|
SSH_PACKET_CALLBACK(ssh_packet_unimplemented);
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
|
SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
|
||||||
SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
|
SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
|
||||||
@@ -63,11 +67,12 @@ SSH_PACKET_CALLBACK(ssh_packet_ext_info);
|
|||||||
SSH_PACKET_CALLBACK(ssh_packet_kexdh_init);
|
SSH_PACKET_CALLBACK(ssh_packet_kexdh_init);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int ssh_packet_send_newkeys(ssh_session session);
|
||||||
int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum);
|
int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum);
|
||||||
int ssh_packet_parse_type(ssh_session session);
|
int ssh_packet_parse_type(ssh_session session);
|
||||||
//int packet_flush(ssh_session session, int enforce_blocking);
|
//int packet_flush(ssh_session session, int enforce_blocking);
|
||||||
|
|
||||||
int ssh_packet_socket_callback(const void *data, size_t len, void *user);
|
size_t ssh_packet_socket_callback(const void *data, size_t len, void *user);
|
||||||
void ssh_packet_register_socket_callback(ssh_session session, struct ssh_socket_struct *s);
|
void ssh_packet_register_socket_callback(ssh_session session, struct ssh_socket_struct *s);
|
||||||
void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
|
void ssh_packet_set_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
|
||||||
void ssh_packet_remove_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
|
void ssh_packet_remove_callbacks(ssh_session session, ssh_packet_callbacks callbacks);
|
||||||
@@ -80,7 +85,7 @@ int ssh_packet_decrypt(ssh_session session, uint8_t *destination, uint8_t *sourc
|
|||||||
size_t start, size_t encrypted_size);
|
size_t start, size_t encrypted_size);
|
||||||
unsigned char *ssh_packet_encrypt(ssh_session session,
|
unsigned char *ssh_packet_encrypt(ssh_session session,
|
||||||
void *packet,
|
void *packet,
|
||||||
unsigned int len);
|
size_t len);
|
||||||
int ssh_packet_hmac_verify(ssh_session session, const void *data, size_t len,
|
int ssh_packet_hmac_verify(ssh_session session, const void *data, size_t len,
|
||||||
unsigned char *mac, enum ssh_hmac_e type);
|
unsigned char *mac, enum ssh_hmac_e type);
|
||||||
int ssh_packet_set_newkeys(ssh_session session,
|
int ssh_packet_set_newkeys(ssh_session session,
|
||||||
@@ -88,4 +93,8 @@ int ssh_packet_set_newkeys(ssh_session session,
|
|||||||
struct ssh_crypto_struct *ssh_packet_get_current_crypto(ssh_session session,
|
struct ssh_crypto_struct *ssh_packet_get_current_crypto(ssh_session session,
|
||||||
enum ssh_crypto_direction_e direction);
|
enum ssh_crypto_direction_e direction);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PACKET_H_ */
|
#endif /* PACKET_H_ */
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
#ifdef WITH_PCAP
|
#ifdef WITH_PCAP
|
||||||
typedef struct ssh_pcap_context_struct* ssh_pcap_context;
|
typedef struct ssh_pcap_context_struct* ssh_pcap_context;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len);
|
int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len);
|
||||||
|
|
||||||
ssh_pcap_context ssh_pcap_context_new(ssh_session session);
|
ssh_pcap_context ssh_pcap_context_new(ssh_session session);
|
||||||
@@ -41,5 +45,9 @@ int ssh_pcap_context_write(ssh_pcap_context,enum ssh_pcap_direction direction, v
|
|||||||
uint32_t len, uint32_t origlen);
|
uint32_t len, uint32_t origlen);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* WITH_PCAP */
|
#endif /* WITH_PCAP */
|
||||||
#endif /* PCAP_H_ */
|
#endif /* PCAP_H_ */
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#ifndef PKI_H_
|
#ifndef PKI_H_
|
||||||
#define PKI_H_
|
#define PKI_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#ifdef HAVE_OPENSSL_EC_H
|
#ifdef HAVE_OPENSSL_EC_H
|
||||||
#include <openssl/ec.h>
|
#include <openssl/ec.h>
|
||||||
@@ -28,10 +29,12 @@
|
|||||||
#ifdef HAVE_OPENSSL_ECDSA_H
|
#ifdef HAVE_OPENSSL_ECDSA_H
|
||||||
#include <openssl/ecdsa.h>
|
#include <openssl/ecdsa.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LIBCRYPTO
|
||||||
|
#include <openssl/evp.h>
|
||||||
|
#endif
|
||||||
#include "libssh/crypto.h"
|
#include "libssh/crypto.h"
|
||||||
#ifdef HAVE_OPENSSL_ED25519
|
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_OPENSSL_ED25519)
|
||||||
/* If using OpenSSL implementation, define the signature lenght which would be
|
/* If using OpenSSL implementation, define the signature length which would be
|
||||||
* defined in libssh/ed25519.h otherwise */
|
* defined in libssh/ed25519.h otherwise */
|
||||||
#define ED25519_SIG_LEN 64
|
#define ED25519_SIG_LEN 64
|
||||||
#else
|
#else
|
||||||
@@ -46,6 +49,7 @@
|
|||||||
#define SSH_KEY_FLAG_EMPTY 0x0
|
#define SSH_KEY_FLAG_EMPTY 0x0
|
||||||
#define SSH_KEY_FLAG_PUBLIC 0x0001
|
#define SSH_KEY_FLAG_PUBLIC 0x0001
|
||||||
#define SSH_KEY_FLAG_PRIVATE 0x0002
|
#define SSH_KEY_FLAG_PRIVATE 0x0002
|
||||||
|
#define SSH_KEY_FLAG_PKCS11_URI 0x0004
|
||||||
|
|
||||||
struct ssh_key_struct {
|
struct ssh_key_struct {
|
||||||
enum ssh_keytypes_e type;
|
enum ssh_keytypes_e type;
|
||||||
@@ -61,21 +65,31 @@ struct ssh_key_struct {
|
|||||||
mbedtls_ecdsa_context *ecdsa;
|
mbedtls_ecdsa_context *ecdsa;
|
||||||
void *dsa;
|
void *dsa;
|
||||||
#elif defined(HAVE_LIBCRYPTO)
|
#elif defined(HAVE_LIBCRYPTO)
|
||||||
|
#if OPENSSL_VERSION_NUMBER < 0x30000000L
|
||||||
DSA *dsa;
|
DSA *dsa;
|
||||||
RSA *rsa;
|
RSA *rsa;
|
||||||
|
#endif /* OPENSSL_VERSION_NUMBER */
|
||||||
|
/* TODO Change to new API when the OpenSSL will support export of uncompressed EC keys
|
||||||
|
* https://github.com/openssl/openssl/pull/16624
|
||||||
|
* Move into the #if above
|
||||||
|
*/
|
||||||
# if defined(HAVE_OPENSSL_ECC)
|
# if defined(HAVE_OPENSSL_ECC)
|
||||||
EC_KEY *ecdsa;
|
EC_KEY *ecdsa;
|
||||||
# else
|
# else
|
||||||
void *ecdsa;
|
void *ecdsa;
|
||||||
# endif /* HAVE_OPENSSL_EC_H */
|
# endif /* HAVE_OPENSSL_EC_H */
|
||||||
|
/* This holds either ENGINE key for PKCS#11 support or just key in
|
||||||
|
* high-level format required by OpenSSL 3.0 */
|
||||||
|
EVP_PKEY *key;
|
||||||
#endif /* HAVE_LIBGCRYPT */
|
#endif /* HAVE_LIBGCRYPT */
|
||||||
#ifdef HAVE_OPENSSL_ED25519
|
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_OPENSSL_ED25519)
|
||||||
uint8_t *ed25519_pubkey;
|
uint8_t *ed25519_pubkey;
|
||||||
uint8_t *ed25519_privkey;
|
uint8_t *ed25519_privkey;
|
||||||
#else
|
#else
|
||||||
ed25519_pubkey *ed25519_pubkey;
|
ed25519_pubkey *ed25519_pubkey;
|
||||||
ed25519_privkey *ed25519_privkey;
|
ed25519_privkey *ed25519_privkey;
|
||||||
#endif
|
#endif
|
||||||
|
ssh_string sk_application;
|
||||||
void *cert;
|
void *cert;
|
||||||
enum ssh_keytypes_e cert_type;
|
enum ssh_keytypes_e cert_type;
|
||||||
};
|
};
|
||||||
@@ -92,16 +106,23 @@ struct ssh_signature_struct {
|
|||||||
ssh_string rsa_sig;
|
ssh_string rsa_sig;
|
||||||
struct mbedtls_ecdsa_sig ecdsa_sig;
|
struct mbedtls_ecdsa_sig ecdsa_sig;
|
||||||
#endif /* HAVE_LIBGCRYPT */
|
#endif /* HAVE_LIBGCRYPT */
|
||||||
#ifndef HAVE_OPENSSL_ED25519
|
#if !defined(HAVE_LIBCRYPTO) || !defined(HAVE_OPENSSL_ED25519)
|
||||||
ed25519_signature *ed25519_sig;
|
ed25519_signature *ed25519_sig;
|
||||||
#endif
|
#endif
|
||||||
ssh_string raw_sig;
|
ssh_string raw_sig;
|
||||||
|
|
||||||
|
/* Security Key specific additions */
|
||||||
|
uint8_t sk_flags;
|
||||||
|
uint32_t sk_counter;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ssh_signature_struct *ssh_signature;
|
typedef struct ssh_signature_struct *ssh_signature;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* SSH Key Functions */
|
/* SSH Key Functions */
|
||||||
ssh_key ssh_key_dup(const ssh_key key);
|
|
||||||
void ssh_key_clean (ssh_key key);
|
void ssh_key_clean (ssh_key key);
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
@@ -119,12 +140,16 @@ enum ssh_digest_e ssh_key_hash_from_name(const char *name);
|
|||||||
#define is_cert_type(kt)\
|
#define is_cert_type(kt)\
|
||||||
((kt) == SSH_KEYTYPE_DSS_CERT01 ||\
|
((kt) == SSH_KEYTYPE_DSS_CERT01 ||\
|
||||||
(kt) == SSH_KEYTYPE_RSA_CERT01 ||\
|
(kt) == SSH_KEYTYPE_RSA_CERT01 ||\
|
||||||
|
(kt) == SSH_KEYTYPE_SK_ECDSA_CERT01 ||\
|
||||||
|
(kt) == SSH_KEYTYPE_SK_ED25519_CERT01 ||\
|
||||||
((kt) >= SSH_KEYTYPE_ECDSA_P256_CERT01 &&\
|
((kt) >= SSH_KEYTYPE_ECDSA_P256_CERT01 &&\
|
||||||
(kt) <= SSH_KEYTYPE_ED25519_CERT01))
|
(kt) <= SSH_KEYTYPE_ED25519_CERT01))
|
||||||
|
|
||||||
/* SSH Signature Functions */
|
/* SSH Signature Functions */
|
||||||
ssh_signature ssh_signature_new(void);
|
ssh_signature ssh_signature_new(void);
|
||||||
void ssh_signature_free(ssh_signature sign);
|
void ssh_signature_free(ssh_signature sign);
|
||||||
|
#define SSH_SIGNATURE_FREE(x) \
|
||||||
|
do { ssh_signature_free(x); x = NULL; } while(0)
|
||||||
|
|
||||||
int ssh_pki_export_signature_blob(const ssh_signature sign,
|
int ssh_pki_export_signature_blob(const ssh_signature sign,
|
||||||
ssh_string *sign_blob);
|
ssh_string *sign_blob);
|
||||||
@@ -162,4 +187,19 @@ ssh_public_key ssh_pki_convert_key_to_publickey(const ssh_key key);
|
|||||||
ssh_private_key ssh_pki_convert_key_to_privatekey(const ssh_key key);
|
ssh_private_key ssh_pki_convert_key_to_privatekey(const ssh_key key);
|
||||||
|
|
||||||
int ssh_key_algorithm_allowed(ssh_session session, const char *type);
|
int ssh_key_algorithm_allowed(ssh_session session, const char *type);
|
||||||
|
bool ssh_key_size_allowed(ssh_session session, ssh_key key);
|
||||||
|
|
||||||
|
/* Return the key size in bits */
|
||||||
|
int ssh_key_size(ssh_key key);
|
||||||
|
|
||||||
|
/* PKCS11 URI function to check if filename is a path or a PKCS11 URI */
|
||||||
|
#ifdef WITH_PKCS11_URI
|
||||||
|
bool ssh_pki_is_uri(const char *filename);
|
||||||
|
char *ssh_pki_export_pub_uri_from_priv_uri(const char *priv_uri);
|
||||||
|
#endif /* WITH_PKCS11_URI */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PKI_H_ */
|
#endif /* PKI_H_ */
|
||||||
|
|||||||
@@ -23,6 +23,10 @@
|
|||||||
|
|
||||||
#include "libssh/pki.h"
|
#include "libssh/pki.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* defined in bcrypt_pbkdf.c */
|
/* defined in bcrypt_pbkdf.c */
|
||||||
int bcrypt_pbkdf(const char *pass,
|
int bcrypt_pbkdf(const char *pass,
|
||||||
size_t passlen,
|
size_t passlen,
|
||||||
@@ -43,6 +47,14 @@ int bcrypt_pbkdf(const char *pass,
|
|||||||
/* Magic defined in OpenSSH/PROTOCOL.key */
|
/* Magic defined in OpenSSH/PROTOCOL.key */
|
||||||
#define OPENSSH_AUTH_MAGIC "openssh-key-v1"
|
#define OPENSSH_AUTH_MAGIC "openssh-key-v1"
|
||||||
|
|
||||||
|
/* Determine type of ssh key. */
|
||||||
|
enum ssh_key_e {
|
||||||
|
SSH_KEY_PUBLIC = 0,
|
||||||
|
SSH_KEY_PRIVATE
|
||||||
|
};
|
||||||
|
|
||||||
|
void pki_key_clean(ssh_key key);
|
||||||
|
|
||||||
int pki_key_ecdsa_nid_from_name(const char *name);
|
int pki_key_ecdsa_nid_from_name(const char *name);
|
||||||
const char *pki_key_ecdsa_nid_to_name(int nid);
|
const char *pki_key_ecdsa_nid_to_name(int nid);
|
||||||
const char *ssh_key_signature_to_char(enum ssh_keytypes_e type,
|
const char *ssh_key_signature_to_char(enum ssh_keytypes_e type,
|
||||||
@@ -141,7 +153,7 @@ int pki_ed25519_verify(const ssh_key pubkey, ssh_signature sig,
|
|||||||
int pki_ed25519_key_cmp(const ssh_key k1,
|
int pki_ed25519_key_cmp(const ssh_key k1,
|
||||||
const ssh_key k2,
|
const ssh_key k2,
|
||||||
enum ssh_keycmp_e what);
|
enum ssh_keycmp_e what);
|
||||||
int pki_ed25519_key_dup(ssh_key new, const ssh_key key);
|
int pki_ed25519_key_dup(ssh_key new_key, const ssh_key key);
|
||||||
int pki_ed25519_public_key_to_blob(ssh_buffer buffer, ssh_key key);
|
int pki_ed25519_public_key_to_blob(ssh_buffer buffer, ssh_key key);
|
||||||
ssh_string pki_ed25519_signature_to_blob(ssh_signature sig);
|
ssh_string pki_ed25519_signature_to_blob(ssh_signature sig);
|
||||||
int pki_signature_from_ed25519_blob(ssh_signature sig, ssh_string sig_blob);
|
int pki_signature_from_ed25519_blob(ssh_signature sig, ssh_string sig_blob);
|
||||||
@@ -156,4 +168,14 @@ ssh_key ssh_pki_openssh_privkey_import(const char *text_key,
|
|||||||
ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
|
ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
|
||||||
const char *passphrase, ssh_auth_callback auth_fn, void *auth_data);
|
const char *passphrase, ssh_auth_callback auth_fn, void *auth_data);
|
||||||
|
|
||||||
|
#ifdef WITH_PKCS11_URI
|
||||||
|
/* URI Function */
|
||||||
|
int pki_uri_import(const char *uri_name, ssh_key *key, enum ssh_key_e key_type);
|
||||||
|
#endif /* WITH_PKCS11_URI */
|
||||||
|
|
||||||
|
bool ssh_key_size_allowed_rsa(int min_size, ssh_key key);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* PKI_PRIV_H_ */
|
#endif /* PKI_PRIV_H_ */
|
||||||
|
|||||||
@@ -114,6 +114,10 @@ typedef unsigned long int nfds_t;
|
|||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
#endif /* HAVE_POLL */
|
#endif /* HAVE_POLL */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
void ssh_poll_init(void);
|
void ssh_poll_init(void);
|
||||||
void ssh_poll_cleanup(void);
|
void ssh_poll_cleanup(void);
|
||||||
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
|
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
|
||||||
@@ -158,4 +162,8 @@ ssh_poll_ctx ssh_poll_get_default_ctx(ssh_session session);
|
|||||||
int ssh_event_add_poll(ssh_event event, ssh_poll_handle p);
|
int ssh_event_add_poll(ssh_event event, ssh_poll_handle p);
|
||||||
void ssh_event_remove_poll(ssh_event event, ssh_poll_handle p);
|
void ssh_event_remove_poll(ssh_event event, ssh_poll_handle p);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* POLL_H_ */
|
#endif /* POLL_H_ */
|
||||||
|
|||||||
@@ -5,9 +5,11 @@
|
|||||||
|
|
||||||
#ifndef POLY1305_H
|
#ifndef POLY1305_H
|
||||||
#define POLY1305_H
|
#define POLY1305_H
|
||||||
|
#include "libssh/chacha20-poly1305-common.h"
|
||||||
|
|
||||||
#define POLY1305_KEYLEN 32
|
#ifdef __cplusplus
|
||||||
#define POLY1305_TAGLEN 16
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen,
|
void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen,
|
||||||
const uint8_t key[POLY1305_KEYLEN])
|
const uint8_t key[POLY1305_KEYLEN])
|
||||||
@@ -18,4 +20,8 @@ void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen,
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* POLY1305_H */
|
#endif /* POLY1305_H */
|
||||||
|
|||||||
@@ -29,9 +29,11 @@
|
|||||||
#ifndef _LIBSSH_PRIV_H
|
#ifndef _LIBSSH_PRIV_H
|
||||||
#define _LIBSSH_PRIV_H
|
#define _LIBSSH_PRIV_H
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#if !defined(HAVE_STRTOULL)
|
#if !defined(HAVE_STRTOULL)
|
||||||
# if defined(HAVE___STRTOULL)
|
# if defined(HAVE___STRTOULL)
|
||||||
@@ -45,6 +47,10 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif /* !defined(HAVE_STRTOULL) */
|
#endif /* !defined(HAVE_STRTOULL) */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(HAVE_STRNDUP)
|
#if !defined(HAVE_STRNDUP)
|
||||||
char *strndup(const char *s, size_t n);
|
char *strndup(const char *s, size_t n);
|
||||||
#endif /* ! HAVE_STRNDUP */
|
#endif /* ! HAVE_STRNDUP */
|
||||||
@@ -65,11 +71,6 @@ char *strndup(const char *s, size_t n);
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
/* Imitate define of inttypes.h */
|
|
||||||
# ifndef PRIdS
|
|
||||||
# define PRIdS "Id"
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef PRIu64
|
# ifndef PRIu64
|
||||||
# if __WORDSIZE == 64
|
# if __WORDSIZE == 64
|
||||||
# define PRIu64 "lu"
|
# define PRIu64 "lu"
|
||||||
@@ -155,14 +156,15 @@ char *strndup(const char *s, size_t n);
|
|||||||
# endif /* _MSC_VER */
|
# endif /* _MSC_VER */
|
||||||
|
|
||||||
struct timeval;
|
struct timeval;
|
||||||
int gettimeofday(struct timeval *__p, void *__t);
|
int ssh_gettimeofday(struct timeval *__p, void *__t);
|
||||||
|
|
||||||
|
#define gettimeofday ssh_gettimeofday
|
||||||
|
|
||||||
#define _XCLOSESOCKET closesocket
|
#define _XCLOSESOCKET closesocket
|
||||||
|
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define PRIdS "zd"
|
|
||||||
|
|
||||||
#define _XCLOSESOCKET close
|
#define _XCLOSESOCKET close
|
||||||
|
|
||||||
@@ -172,7 +174,15 @@ int gettimeofday(struct timeval *__p, void *__t);
|
|||||||
#include "libssh/callbacks.h"
|
#include "libssh/callbacks.h"
|
||||||
|
|
||||||
/* some constants */
|
/* some constants */
|
||||||
#ifndef MAX_PACKAT_LEN
|
#ifndef PATH_MAX
|
||||||
|
#ifdef MAX_PATH
|
||||||
|
#define PATH_MAX MAX_PATH
|
||||||
|
#else
|
||||||
|
#define PATH_MAX 4096
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX_PACKET_LEN
|
||||||
#define MAX_PACKET_LEN 262144
|
#define MAX_PACKET_LEN 262144
|
||||||
#endif
|
#endif
|
||||||
#ifndef ERROR_BUFFERLEN
|
#ifndef ERROR_BUFFERLEN
|
||||||
@@ -287,7 +297,7 @@ socket_t ssh_connect_host_nonblocking(ssh_session session, const char *host,
|
|||||||
|
|
||||||
/* in base64.c */
|
/* in base64.c */
|
||||||
ssh_buffer base64_to_bin(const char *source);
|
ssh_buffer base64_to_bin(const char *source);
|
||||||
unsigned char *bin_to_base64(const unsigned char *source, int len);
|
uint8_t *bin_to_base64(const uint8_t *source, size_t len);
|
||||||
|
|
||||||
/* gzip.c */
|
/* gzip.c */
|
||||||
int compress_buffer(ssh_session session,ssh_buffer buf);
|
int compress_buffer(ssh_session session,ssh_buffer buf);
|
||||||
@@ -295,7 +305,7 @@ int decompress_buffer(ssh_session session,ssh_buffer buf, size_t maxlen);
|
|||||||
|
|
||||||
/* match.c */
|
/* match.c */
|
||||||
int match_pattern_list(const char *string, const char *pattern,
|
int match_pattern_list(const char *string, const char *pattern,
|
||||||
unsigned int len, int dolower);
|
size_t len, int dolower);
|
||||||
int match_hostname(const char *host, const char *pattern, unsigned int len);
|
int match_hostname(const char *host, const char *pattern, unsigned int len);
|
||||||
|
|
||||||
/* connector.c */
|
/* connector.c */
|
||||||
@@ -346,7 +356,7 @@ void explicit_bzero(void *s, size_t n);
|
|||||||
#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
|
#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the argument cound of variadic arguments
|
* Get the argument count of variadic arguments
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Since MSVC 2010 there is a bug in passing __VA_ARGS__ to subsequent
|
* Since MSVC 2010 there is a bug in passing __VA_ARGS__ to subsequent
|
||||||
@@ -405,22 +415,31 @@ void explicit_bzero(void *s, size_t n);
|
|||||||
# endif /* HAVE_FALLTHROUGH_ATTRIBUTE */
|
# endif /* HAVE_FALLTHROUGH_ATTRIBUTE */
|
||||||
#endif /* FALL_THROUGH */
|
#endif /* FALL_THROUGH */
|
||||||
|
|
||||||
#ifndef __unused__
|
#ifndef __attr_unused__
|
||||||
# ifdef HAVE_UNUSED_ATTRIBUTE
|
# ifdef HAVE_UNUSED_ATTRIBUTE
|
||||||
# define __unused__ __attribute__((unused))
|
# define __attr_unused__ __attribute__((unused))
|
||||||
# else /* HAVE_UNUSED_ATTRIBUTE */
|
# else /* HAVE_UNUSED_ATTRIBUTE */
|
||||||
# define __unused__
|
# define __attr_unused__
|
||||||
# endif /* HAVE_UNUSED_ATTRIBUTE */
|
# endif /* HAVE_UNUSED_ATTRIBUTE */
|
||||||
#endif /* __unused__ */
|
#endif /* __attr_unused__ */
|
||||||
|
|
||||||
#ifndef UNUSED_PARAM
|
#ifndef UNUSED_PARAM
|
||||||
#define UNUSED_PARAM(param) param __unused__
|
#define UNUSED_PARAM(param) param __attr_unused__
|
||||||
#endif /* UNUSED_PARAM */
|
#endif /* UNUSED_PARAM */
|
||||||
|
|
||||||
#ifndef UNUSED_VAR
|
#ifndef UNUSED_VAR
|
||||||
#define UNUSED_VAR(var) __unused__ var
|
#define UNUSED_VAR(var) __attr_unused__ var
|
||||||
#endif /* UNUSED_VAR */
|
#endif /* UNUSED_VAR */
|
||||||
|
|
||||||
void ssh_agent_state_free(void *data);
|
void ssh_agent_state_free(void *data);
|
||||||
|
|
||||||
|
bool is_ssh_initialized(void);
|
||||||
|
|
||||||
|
#define SSH_ERRNO_MSG_MAX 1024
|
||||||
|
char *ssh_strerror(int err_num, char *buf, size_t buflen);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _LIBSSH_PRIV_H */
|
#endif /* _LIBSSH_PRIV_H */
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ typedef struct {
|
|||||||
uint32_t v[16];
|
uint32_t v[16];
|
||||||
} shortsc25519;
|
} shortsc25519;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
|
void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
|
||||||
|
|
||||||
void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]);
|
void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]);
|
||||||
@@ -71,4 +75,8 @@ void sc25519_window5(signed char r[51], const sc25519 *s);
|
|||||||
|
|
||||||
void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2);
|
void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -47,9 +47,17 @@ struct ssh_scp_struct {
|
|||||||
int request_mode;
|
int request_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len);
|
int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len);
|
||||||
int ssh_scp_integer_mode(const char *mode);
|
int ssh_scp_integer_mode(const char *mode);
|
||||||
char *ssh_scp_string_mode(int mode);
|
char *ssh_scp_string_mode(int mode);
|
||||||
int ssh_scp_response(ssh_scp scp, char **response);
|
int ssh_scp_response(ssh_scp scp, char **response);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ enum ssh_bind_options_e {
|
|||||||
SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES,
|
||||||
SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS,
|
||||||
SSH_BIND_OPTIONS_PROCESS_CONFIG,
|
SSH_BIND_OPTIONS_PROCESS_CONFIG,
|
||||||
|
SSH_BIND_OPTIONS_MODULI,
|
||||||
|
SSH_BIND_OPTIONS_RSA_MIN_SIZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct ssh_bind_struct* ssh_bind;
|
typedef struct ssh_bind_struct* ssh_bind;
|
||||||
@@ -115,7 +117,7 @@ LIBSSH_API int ssh_bind_listen(ssh_bind ssh_bind_o);
|
|||||||
*
|
*
|
||||||
* @param[in] userdata A pointer to private data to pass to the callbacks.
|
* @param[in] userdata A pointer to private data to pass to the callbacks.
|
||||||
*
|
*
|
||||||
* @return SSH_OK on success, SSH_ERROR if an error occured.
|
* @return SSH_OK on success, SSH_ERROR if an error occurred.
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* struct ssh_callbacks_struct cb = {
|
* struct ssh_callbacks_struct cb = {
|
||||||
@@ -243,6 +245,18 @@ LIBSSH_API void ssh_bind_free(ssh_bind ssh_bind_o);
|
|||||||
*/
|
*/
|
||||||
LIBSSH_API void ssh_set_auth_methods(ssh_session session, int auth_methods);
|
LIBSSH_API void ssh_set_auth_methods(ssh_session session, int auth_methods);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Send the server's issue-banner to client.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param[in] session The server session.
|
||||||
|
*
|
||||||
|
* @param[in] banner The server's banner.
|
||||||
|
*
|
||||||
|
* @return SSH_OK on success, SSH_ERROR on error.
|
||||||
|
*/
|
||||||
|
LIBSSH_API int ssh_send_issue_banner(ssh_session session, const ssh_string banner);
|
||||||
|
|
||||||
/**********************************************************
|
/**********************************************************
|
||||||
* SERVER MESSAGING
|
* SERVER MESSAGING
|
||||||
**********************************************************/
|
**********************************************************/
|
||||||
@@ -266,7 +280,7 @@ LIBSSH_API int ssh_message_reply_default(ssh_message msg);
|
|||||||
*
|
*
|
||||||
* @param[in] msg The message to get the username from.
|
* @param[in] msg The message to get the username from.
|
||||||
*
|
*
|
||||||
* @return The username or NULL if an error occured.
|
* @return The username or NULL if an error occurred.
|
||||||
*
|
*
|
||||||
* @see ssh_message_get()
|
* @see ssh_message_get()
|
||||||
* @see ssh_message_type()
|
* @see ssh_message_type()
|
||||||
@@ -278,12 +292,14 @@ LIBSSH_API const char *ssh_message_auth_user(ssh_message msg);
|
|||||||
*
|
*
|
||||||
* @param[in] msg The message to get the password from.
|
* @param[in] msg The message to get the password from.
|
||||||
*
|
*
|
||||||
* @return The username or NULL if an error occured.
|
* @return The username or NULL if an error occurred.
|
||||||
*
|
*
|
||||||
* @see ssh_message_get()
|
* @see ssh_message_get()
|
||||||
* @see ssh_message_type()
|
* @see ssh_message_type()
|
||||||
|
* @deprecated This function should not be used anymore as there is a
|
||||||
|
* callback based server implementation now auth_password_function.
|
||||||
*/
|
*/
|
||||||
LIBSSH_API const char *ssh_message_auth_password(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API const char *ssh_message_auth_password(ssh_message msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the publickey of the authenticated user.
|
* @brief Get the publickey of the authenticated user.
|
||||||
@@ -298,11 +314,21 @@ LIBSSH_API const char *ssh_message_auth_password(ssh_message msg);
|
|||||||
* @see ssh_key_cmp()
|
* @see ssh_key_cmp()
|
||||||
* @see ssh_message_get()
|
* @see ssh_message_get()
|
||||||
* @see ssh_message_type()
|
* @see ssh_message_type()
|
||||||
|
* @deprecated This function should not be used anymore as there is a
|
||||||
|
* callback based server implementation auth_pubkey_function.
|
||||||
*/
|
*/
|
||||||
LIBSSH_API ssh_key ssh_message_auth_pubkey(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API ssh_key ssh_message_auth_pubkey(ssh_message msg);
|
||||||
|
|
||||||
LIBSSH_API int ssh_message_auth_kbdint_is_response(ssh_message msg);
|
LIBSSH_API int ssh_message_auth_kbdint_is_response(ssh_message msg);
|
||||||
LIBSSH_API enum ssh_publickey_state_e ssh_message_auth_publickey_state(ssh_message msg);
|
|
||||||
|
/**
|
||||||
|
* @param[in] msg The message to get the public key state from.
|
||||||
|
*
|
||||||
|
* @deprecated This function should not be used anymore as there is a
|
||||||
|
* callback based server implementation auth_pubkey_function
|
||||||
|
*/
|
||||||
|
SSH_DEPRECATED LIBSSH_API enum ssh_publickey_state_e ssh_message_auth_publickey_state(ssh_message msg);
|
||||||
|
|
||||||
LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial);
|
LIBSSH_API int ssh_message_auth_reply_success(ssh_message msg,int partial);
|
||||||
LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey);
|
LIBSSH_API int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pubkey);
|
||||||
LIBSSH_API int ssh_message_auth_reply_pk_ok_simple(ssh_message msg);
|
LIBSSH_API int ssh_message_auth_reply_pk_ok_simple(ssh_message msg);
|
||||||
@@ -331,11 +357,12 @@ LIBSSH_API int ssh_message_channel_request_open_destination_port(ssh_message msg
|
|||||||
|
|
||||||
LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg);
|
LIBSSH_API ssh_channel ssh_message_channel_request_channel(ssh_message msg);
|
||||||
|
|
||||||
LIBSSH_API const char *ssh_message_channel_request_pty_term(ssh_message msg);
|
/* Replaced by callback based server implementation function channel_pty_request_function*/
|
||||||
LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API const char *ssh_message_channel_request_pty_term(ssh_message msg);
|
||||||
LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_pty_width(ssh_message msg);
|
||||||
LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_pty_height(ssh_message msg);
|
||||||
LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_pty_pxwidth(ssh_message msg);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_pty_pxheight(ssh_message msg);
|
||||||
|
|
||||||
LIBSSH_API const char *ssh_message_channel_request_env_name(ssh_message msg);
|
LIBSSH_API const char *ssh_message_channel_request_env_name(ssh_message msg);
|
||||||
LIBSSH_API const char *ssh_message_channel_request_env_value(ssh_message msg);
|
LIBSSH_API const char *ssh_message_channel_request_env_value(ssh_message msg);
|
||||||
@@ -344,17 +371,18 @@ LIBSSH_API const char *ssh_message_channel_request_command(ssh_message msg);
|
|||||||
|
|
||||||
LIBSSH_API const char *ssh_message_channel_request_subsystem(ssh_message msg);
|
LIBSSH_API const char *ssh_message_channel_request_subsystem(ssh_message msg);
|
||||||
|
|
||||||
LIBSSH_API int ssh_message_channel_request_x11_single_connection(ssh_message msg);
|
/* Replaced by callback based server implementation function channel_open_request_x11_function*/
|
||||||
LIBSSH_API const char *ssh_message_channel_request_x11_auth_protocol(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_x11_single_connection(ssh_message msg);
|
||||||
LIBSSH_API const char *ssh_message_channel_request_x11_auth_cookie(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API const char *ssh_message_channel_request_x11_auth_protocol(ssh_message msg);
|
||||||
LIBSSH_API int ssh_message_channel_request_x11_screen_number(ssh_message msg);
|
SSH_DEPRECATED LIBSSH_API const char *ssh_message_channel_request_x11_auth_cookie(ssh_message msg);
|
||||||
|
SSH_DEPRECATED LIBSSH_API int ssh_message_channel_request_x11_screen_number(ssh_message msg);
|
||||||
|
|
||||||
LIBSSH_API const char *ssh_message_global_request_address(ssh_message msg);
|
LIBSSH_API const char *ssh_message_global_request_address(ssh_message msg);
|
||||||
LIBSSH_API int ssh_message_global_request_port(ssh_message msg);
|
LIBSSH_API int ssh_message_global_request_port(ssh_message msg);
|
||||||
|
|
||||||
LIBSSH_API int ssh_channel_open_reverse_forward(ssh_channel channel, const char *remotehost,
|
LIBSSH_API int ssh_channel_open_reverse_forward(ssh_channel channel, const char *remotehost,
|
||||||
int remoteport, const char *sourcehost, int localport);
|
int remoteport, const char *sourcehost, int localport);
|
||||||
LIBSSH_API int ssh_channel_open_x11(ssh_channel channel,
|
LIBSSH_API int ssh_channel_open_x11(ssh_channel channel,
|
||||||
const char *orig_addr, int orig_port);
|
const char *orig_addr, int orig_port);
|
||||||
|
|
||||||
LIBSSH_API int ssh_channel_request_send_exit_status(ssh_channel channel,
|
LIBSSH_API int ssh_channel_request_send_exit_status(ssh_channel channel,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/callbacks.h"
|
||||||
#include "libssh/kex.h"
|
#include "libssh/kex.h"
|
||||||
#include "libssh/packet.h"
|
#include "libssh/packet.h"
|
||||||
#include "libssh/pcap.h"
|
#include "libssh/pcap.h"
|
||||||
@@ -75,6 +76,17 @@ enum ssh_pending_call_e {
|
|||||||
/* Client successfully authenticated */
|
/* Client successfully authenticated */
|
||||||
#define SSH_SESSION_FLAG_AUTHENTICATED 2
|
#define SSH_SESSION_FLAG_AUTHENTICATED 2
|
||||||
|
|
||||||
|
/* The KEXINIT message can be sent first by either of the parties so this flag
|
||||||
|
* indicates that the message was already sent to make sure it is sent and avoid
|
||||||
|
* sending it twice during key exchange to simplify the state machine. */
|
||||||
|
#define SSH_SESSION_FLAG_KEXINIT_SENT 4
|
||||||
|
|
||||||
|
/* The current SSH2 session implements the "strict KEX" feature and should behave
|
||||||
|
* differently on SSH2_MSG_NEWKEYS. */
|
||||||
|
#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
|
||||||
|
/* Unexpected packets have been sent while the session was still unencrypted */
|
||||||
|
#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
|
||||||
|
|
||||||
/* codes to use with ssh_handle_packets*() */
|
/* codes to use with ssh_handle_packets*() */
|
||||||
/* Infinite timeout */
|
/* Infinite timeout */
|
||||||
#define SSH_TIMEOUT_INFINITE -1
|
#define SSH_TIMEOUT_INFINITE -1
|
||||||
@@ -92,6 +104,12 @@ enum ssh_pending_call_e {
|
|||||||
#define SSH_OPT_FLAG_KBDINT_AUTH 0x4
|
#define SSH_OPT_FLAG_KBDINT_AUTH 0x4
|
||||||
#define SSH_OPT_FLAG_GSSAPI_AUTH 0x8
|
#define SSH_OPT_FLAG_GSSAPI_AUTH 0x8
|
||||||
|
|
||||||
|
/* Escape expansion of different variables */
|
||||||
|
#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
|
||||||
|
#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
|
||||||
|
#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
|
||||||
|
#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
|
||||||
|
|
||||||
/* extensions flags */
|
/* extensions flags */
|
||||||
/* negotiation enabled */
|
/* negotiation enabled */
|
||||||
#define SSH_EXT_NEGOTIATION 0x01
|
#define SSH_EXT_NEGOTIATION 0x01
|
||||||
@@ -131,10 +149,9 @@ struct ssh_session_struct {
|
|||||||
/* Extensions negotiated using RFC 8308 */
|
/* Extensions negotiated using RFC 8308 */
|
||||||
uint32_t extensions;
|
uint32_t extensions;
|
||||||
|
|
||||||
ssh_string banner; /* that's the issue banner from
|
ssh_string banner; /* that's the issue banner from the server */
|
||||||
the server */
|
char *peer_discon_msg; /* disconnect message from the remote host */
|
||||||
char *discon_msg; /* disconnect message from
|
char *disconnect_message; /* disconnect message to be set */
|
||||||
the remote host */
|
|
||||||
ssh_buffer in_buffer;
|
ssh_buffer in_buffer;
|
||||||
PACKET in_packet;
|
PACKET in_packet;
|
||||||
ssh_buffer out_buffer;
|
ssh_buffer out_buffer;
|
||||||
@@ -145,7 +162,7 @@ struct ssh_session_struct {
|
|||||||
/* where it was before being interrupted */
|
/* where it was before being interrupted */
|
||||||
enum ssh_pending_call_e pending_call_state;
|
enum ssh_pending_call_e pending_call_state;
|
||||||
enum ssh_session_state_e session_state;
|
enum ssh_session_state_e session_state;
|
||||||
int packet_state;
|
enum ssh_packet_state_e packet_state;
|
||||||
enum ssh_dh_state_e dh_handshake_state;
|
enum ssh_dh_state_e dh_handshake_state;
|
||||||
enum ssh_channel_request_state_e global_req_state;
|
enum ssh_channel_request_state_e global_req_state;
|
||||||
struct ssh_agent_state_struct *agent_state;
|
struct ssh_agent_state_struct *agent_state;
|
||||||
@@ -158,25 +175,33 @@ struct ssh_session_struct {
|
|||||||
uint32_t current_method;
|
uint32_t current_method;
|
||||||
} auth;
|
} auth;
|
||||||
|
|
||||||
|
/* Sending this flag before key exchange to save one round trip during the
|
||||||
|
* key exchange. This might make sense on high-latency connections.
|
||||||
|
* So far internal only for testing. Usable only on the client side --
|
||||||
|
* there is no key exchange method that would start with server message */
|
||||||
|
bool send_first_kex_follows;
|
||||||
/*
|
/*
|
||||||
* RFC 4253, 7.1: if the first_kex_packet_follows flag was set in
|
* RFC 4253, 7.1: if the first_kex_packet_follows flag was set in
|
||||||
* the received SSH_MSG_KEXINIT, but the guess was wrong, this
|
* the received SSH_MSG_KEXINIT, but the guess was wrong, this
|
||||||
* field will be set such that the following guessed packet will
|
* field will be set such that the following guessed packet will
|
||||||
* be ignored. Once that packet has been received and ignored,
|
* be ignored on the receiving side. Once that packet has been received and
|
||||||
* this field is cleared.
|
* ignored, this field is cleared.
|
||||||
|
* On the sending side, this is set after we got peer KEXINIT message and we
|
||||||
|
* need to resend the initial message of the negotiated KEX algorithm.
|
||||||
*/
|
*/
|
||||||
int first_kex_follows_guess_wrong;
|
bool first_kex_follows_guess_wrong;
|
||||||
|
|
||||||
ssh_buffer in_hashbuf;
|
ssh_buffer in_hashbuf;
|
||||||
ssh_buffer out_hashbuf;
|
ssh_buffer out_hashbuf;
|
||||||
struct ssh_crypto_struct *current_crypto;
|
struct ssh_crypto_struct *current_crypto;
|
||||||
struct ssh_crypto_struct *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */
|
/* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */
|
||||||
|
struct ssh_crypto_struct *next_crypto;
|
||||||
|
|
||||||
struct ssh_list *channels; /* linked list of channels */
|
struct ssh_list *channels; /* linked list of channels */
|
||||||
int maxchannel;
|
uint32_t maxchannel;
|
||||||
ssh_agent agent; /* ssh agent */
|
ssh_agent agent; /* ssh agent */
|
||||||
|
|
||||||
/* keyb interactive data */
|
/* keyboard interactive data */
|
||||||
struct ssh_kbdint_struct *kbdint;
|
struct ssh_kbdint_struct *kbdint;
|
||||||
struct ssh_gssapi_struct *gssapi;
|
struct ssh_gssapi_struct *gssapi;
|
||||||
|
|
||||||
@@ -193,7 +218,8 @@ struct ssh_session_struct {
|
|||||||
|
|
||||||
/* auths accepted by server */
|
/* auths accepted by server */
|
||||||
struct ssh_list *ssh_message_list; /* list of delayed SSH messages */
|
struct ssh_list *ssh_message_list; /* list of delayed SSH messages */
|
||||||
int (*ssh_message_callback)( struct ssh_session_struct *session, ssh_message msg, void *userdata);
|
int (*ssh_message_callback)(struct ssh_session_struct *session,
|
||||||
|
ssh_message msg, void *userdata);
|
||||||
void *ssh_message_callback_data;
|
void *ssh_message_callback_data;
|
||||||
ssh_server_callbacks server_callbacks;
|
ssh_server_callbacks server_callbacks;
|
||||||
void (*ssh_connection_callback)( struct ssh_session_struct *session);
|
void (*ssh_connection_callback)( struct ssh_session_struct *session);
|
||||||
@@ -207,19 +233,22 @@ struct ssh_session_struct {
|
|||||||
#endif
|
#endif
|
||||||
struct {
|
struct {
|
||||||
struct ssh_list *identity;
|
struct ssh_list *identity;
|
||||||
|
struct ssh_list *identity_non_exp;
|
||||||
char *username;
|
char *username;
|
||||||
char *host;
|
char *host;
|
||||||
char *bindaddr; /* bind the client to an ip addr */
|
char *bindaddr; /* bind the client to an ip addr */
|
||||||
char *sshdir;
|
char *sshdir;
|
||||||
char *knownhosts;
|
char *knownhosts;
|
||||||
char *global_knownhosts;
|
char *global_knownhosts;
|
||||||
char *wanted_methods[10];
|
char *wanted_methods[SSH_KEX_METHODS];
|
||||||
char *pubkey_accepted_types;
|
char *pubkey_accepted_types;
|
||||||
char *ProxyCommand;
|
char *ProxyCommand;
|
||||||
char *custombanner;
|
char *custombanner;
|
||||||
|
char *moduli_file;
|
||||||
|
char *agent_socket;
|
||||||
unsigned long timeout; /* seconds */
|
unsigned long timeout; /* seconds */
|
||||||
unsigned long timeout_usec;
|
unsigned long timeout_usec;
|
||||||
unsigned int port;
|
uint16_t port;
|
||||||
socket_t fd;
|
socket_t fd;
|
||||||
int StrictHostKeyChecking;
|
int StrictHostKeyChecking;
|
||||||
char compressionlevel;
|
char compressionlevel;
|
||||||
@@ -227,11 +256,13 @@ struct ssh_session_struct {
|
|||||||
char *gss_client_identity;
|
char *gss_client_identity;
|
||||||
int gss_delegate_creds;
|
int gss_delegate_creds;
|
||||||
int flags;
|
int flags;
|
||||||
|
int exp_flags;
|
||||||
int nodelay;
|
int nodelay;
|
||||||
bool config_processed;
|
bool config_processed;
|
||||||
uint8_t options_seen[SOC_MAX];
|
uint8_t options_seen[SOC_MAX];
|
||||||
uint64_t rekey_data;
|
uint64_t rekey_data;
|
||||||
uint32_t rekey_time;
|
uint32_t rekey_time;
|
||||||
|
int rsa_min_size;
|
||||||
} opts;
|
} opts;
|
||||||
/* counters */
|
/* counters */
|
||||||
ssh_counter socket_counter;
|
ssh_counter socket_counter;
|
||||||
@@ -246,7 +277,7 @@ struct ssh_session_struct {
|
|||||||
typedef int (*ssh_termination_function)(void *user);
|
typedef int (*ssh_termination_function)(void *user);
|
||||||
int ssh_handle_packets(ssh_session session, int timeout);
|
int ssh_handle_packets(ssh_session session, int timeout);
|
||||||
int ssh_handle_packets_termination(ssh_session session,
|
int ssh_handle_packets_termination(ssh_session session,
|
||||||
long timeout,
|
int timeout,
|
||||||
ssh_termination_function fct,
|
ssh_termination_function fct,
|
||||||
void *user);
|
void *user);
|
||||||
void ssh_socket_exception_callback(int code, int errno_code, void *user);
|
void ssh_socket_exception_callback(int code, int errno_code, void *user);
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ LIBSSH_API int sftp_init(sftp_session sftp);
|
|||||||
* @param sftp The sftp session where the error is saved.
|
* @param sftp The sftp session where the error is saved.
|
||||||
*
|
*
|
||||||
* @return The saved error (see server responses), < 0 if an error
|
* @return The saved error (see server responses), < 0 if an error
|
||||||
* in the function occured.
|
* in the function occurred.
|
||||||
*
|
*
|
||||||
* @see Server responses
|
* @see Server responses
|
||||||
*/
|
*/
|
||||||
@@ -413,7 +413,7 @@ LIBSSH_API void sftp_attributes_free(sftp_attributes file);
|
|||||||
*
|
*
|
||||||
* @param dir The sftp directory handle to close.
|
* @param dir The sftp directory handle to close.
|
||||||
*
|
*
|
||||||
* @return Returns SSH_NO_ERROR or SSH_ERROR if an error occured.
|
* @return Returns SSH_NO_ERROR or SSH_ERROR if an error occurred.
|
||||||
*/
|
*/
|
||||||
LIBSSH_API int sftp_closedir(sftp_dir dir);
|
LIBSSH_API int sftp_closedir(sftp_dir dir);
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ LIBSSH_API int sftp_closedir(sftp_dir dir);
|
|||||||
*
|
*
|
||||||
* @param file The open sftp file handle to close.
|
* @param file The open sftp file handle to close.
|
||||||
*
|
*
|
||||||
* @return Returns SSH_NO_ERROR or SSH_ERROR if an error occured.
|
* @return Returns SSH_NO_ERROR or SSH_ERROR if an error occurred.
|
||||||
*
|
*
|
||||||
* @see sftp_open()
|
* @see sftp_open()
|
||||||
*/
|
*/
|
||||||
@@ -478,7 +478,7 @@ LIBSSH_API void sftp_file_set_blocking(sftp_file handle);
|
|||||||
*
|
*
|
||||||
* @param file The opened sftp file handle to be read from.
|
* @param file The opened sftp file handle to be read from.
|
||||||
*
|
*
|
||||||
* @param buf Pointer to buffer to recieve read data.
|
* @param buf Pointer to buffer to receive read data.
|
||||||
*
|
*
|
||||||
* @param count Size of the buffer in bytes.
|
* @param count Size of the buffer in bytes.
|
||||||
*
|
*
|
||||||
@@ -527,7 +527,7 @@ LIBSSH_API int sftp_async_read_begin(sftp_file file, uint32_t len);
|
|||||||
*
|
*
|
||||||
* @param file The opened sftp file handle to be read from.
|
* @param file The opened sftp file handle to be read from.
|
||||||
*
|
*
|
||||||
* @param data Pointer to buffer to recieve read data.
|
* @param data Pointer to buffer to receive read data.
|
||||||
*
|
*
|
||||||
* @param len Size of the buffer in bytes. It should be bigger or
|
* @param len Size of the buffer in bytes. It should be bigger or
|
||||||
* equal to the length parameter of the
|
* equal to the length parameter of the
|
||||||
@@ -537,7 +537,7 @@ LIBSSH_API int sftp_async_read_begin(sftp_file file, uint32_t len);
|
|||||||
* function.
|
* function.
|
||||||
*
|
*
|
||||||
* @return Number of bytes read, 0 on EOF, SSH_ERROR if an error
|
* @return Number of bytes read, 0 on EOF, SSH_ERROR if an error
|
||||||
* occured, SSH_AGAIN if the file is opened in nonblocking
|
* occurred, SSH_AGAIN if the file is opened in nonblocking
|
||||||
* mode and the request hasn't been executed yet.
|
* mode and the request hasn't been executed yet.
|
||||||
*
|
*
|
||||||
* @warning A call to this function with an invalid identifier
|
* @warning A call to this function with an invalid identifier
|
||||||
@@ -632,7 +632,7 @@ LIBSSH_API void sftp_rewind(sftp_file file);
|
|||||||
LIBSSH_API int sftp_unlink(sftp_session sftp, const char *file);
|
LIBSSH_API int sftp_unlink(sftp_session sftp, const char *file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Remove a directoy.
|
* @brief Remove a directory.
|
||||||
*
|
*
|
||||||
* @param sftp The sftp session handle.
|
* @param sftp The sftp session handle.
|
||||||
*
|
*
|
||||||
@@ -681,6 +681,11 @@ LIBSSH_API int sftp_rename(sftp_session sftp, const char *original, const char
|
|||||||
/**
|
/**
|
||||||
* @brief Set file attributes on a file, directory or symbolic link.
|
* @brief Set file attributes on a file, directory or symbolic link.
|
||||||
*
|
*
|
||||||
|
* Note, that this function can only set time values using 32 bit values due to
|
||||||
|
* the restrictions in the SFTP protocol version 3 implemented by libssh.
|
||||||
|
* The support for 64 bit time values was introduced in SFTP version 5, which is
|
||||||
|
* not implemented by libssh nor any major SFTP servers.
|
||||||
|
*
|
||||||
* @param sftp The sftp session handle.
|
* @param sftp The sftp session handle.
|
||||||
*
|
*
|
||||||
* @param file The file which attributes should be changed.
|
* @param file The file which attributes should be changed.
|
||||||
@@ -767,6 +772,8 @@ LIBSSH_API int sftp_symlink(sftp_session sftp, const char *target, const char *d
|
|||||||
* @param path Specifies the path name of the symlink to be read.
|
* @param path Specifies the path name of the symlink to be read.
|
||||||
*
|
*
|
||||||
* @return The target of the link, NULL on error.
|
* @return The target of the link, NULL on error.
|
||||||
|
* The caller needs to free the memory
|
||||||
|
* using ssh_string_free_char().
|
||||||
*
|
*
|
||||||
* @see sftp_get_error()
|
* @see sftp_get_error()
|
||||||
*/
|
*/
|
||||||
@@ -806,7 +813,7 @@ LIBSSH_API void sftp_statvfs_free(sftp_statvfs_t statvfs_o);
|
|||||||
/**
|
/**
|
||||||
* @brief Synchronize a file's in-core state with storage device
|
* @brief Synchronize a file's in-core state with storage device
|
||||||
*
|
*
|
||||||
* This calls the "fsync@openssh.com" extention. You should check if the
|
* This calls the "fsync@openssh.com" extension. You should check if the
|
||||||
* extensions is supported using:
|
* extensions is supported using:
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
@@ -854,7 +861,7 @@ LIBSSH_API int sftp_server_version(sftp_session sftp);
|
|||||||
LIBSSH_API sftp_session sftp_server_new(ssh_session session, ssh_channel chan);
|
LIBSSH_API sftp_session sftp_server_new(ssh_session session, ssh_channel chan);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Intialize the sftp server.
|
* @brief Initialize the sftp server.
|
||||||
*
|
*
|
||||||
* @param sftp The sftp session to init.
|
* @param sftp The sftp session to init.
|
||||||
*
|
*
|
||||||
@@ -870,13 +877,6 @@ LIBSSH_API int sftp_server_init(sftp_session sftp);
|
|||||||
LIBSSH_API void sftp_server_free(sftp_session sftp);
|
LIBSSH_API void sftp_server_free(sftp_session sftp);
|
||||||
#endif /* WITH_SERVER */
|
#endif /* WITH_SERVER */
|
||||||
|
|
||||||
/* this is not a public interface */
|
|
||||||
#define SFTP_HANDLES 256
|
|
||||||
sftp_packet sftp_packet_read(sftp_session sftp);
|
|
||||||
int sftp_packet_write(sftp_session sftp,uint8_t type, ssh_buffer payload);
|
|
||||||
void sftp_packet_free(sftp_packet packet);
|
|
||||||
int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr);
|
|
||||||
sftp_attributes sftp_parse_attr(sftp_session session, ssh_buffer buf,int expectname);
|
|
||||||
/* sftpserver.c */
|
/* sftpserver.c */
|
||||||
|
|
||||||
LIBSSH_API sftp_client_message sftp_get_client_message(sftp_session sftp);
|
LIBSSH_API sftp_client_message sftp_get_client_message(sftp_session sftp);
|
||||||
|
|||||||
40
include/libssh/sftp_priv.h
Normal file
40
include/libssh/sftp_priv.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the SSH Library
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-2008 by Aris Adamantiadis
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SFTP_PRIV_H
|
||||||
|
#define SFTP_PRIV_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
sftp_packet sftp_packet_read(sftp_session sftp);
|
||||||
|
int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload);
|
||||||
|
void sftp_packet_free(sftp_packet packet);
|
||||||
|
int buffer_add_attributes(ssh_buffer buffer, sftp_attributes attr);
|
||||||
|
sftp_attributes sftp_parse_attr(sftp_session session,
|
||||||
|
ssh_buffer buf,
|
||||||
|
int expectname);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* SFTP_PRIV_H */
|
||||||
@@ -35,13 +35,14 @@ void ssh_socket_reset(ssh_socket s);
|
|||||||
void ssh_socket_free(ssh_socket s);
|
void ssh_socket_free(ssh_socket s);
|
||||||
void ssh_socket_set_fd(ssh_socket s, socket_t fd);
|
void ssh_socket_set_fd(ssh_socket s, socket_t fd);
|
||||||
socket_t ssh_socket_get_fd(ssh_socket s);
|
socket_t ssh_socket_get_fd(ssh_socket s);
|
||||||
#ifndef _WIN32
|
void ssh_socket_set_connected(ssh_socket s, struct ssh_poll_handle_struct *p);
|
||||||
int ssh_socket_unix(ssh_socket s, const char *path);
|
int ssh_socket_unix(ssh_socket s, const char *path);
|
||||||
void ssh_execute_command(const char *command, socket_t in, socket_t out);
|
void ssh_execute_command(const char *command, socket_t in, socket_t out);
|
||||||
|
#ifndef _WIN32
|
||||||
int ssh_socket_connect_proxycommand(ssh_socket s, const char *command);
|
int ssh_socket_connect_proxycommand(ssh_socket s, const char *command);
|
||||||
#endif
|
#endif
|
||||||
void ssh_socket_close(ssh_socket s);
|
void ssh_socket_close(ssh_socket s);
|
||||||
int ssh_socket_write(ssh_socket s,const void *buffer, int len);
|
int ssh_socket_write(ssh_socket s,const void *buffer, uint32_t len);
|
||||||
int ssh_socket_is_open(ssh_socket s);
|
int ssh_socket_is_open(ssh_socket s);
|
||||||
int ssh_socket_fd_isset(ssh_socket s, fd_set *set);
|
int ssh_socket_fd_isset(ssh_socket s, fd_set *set);
|
||||||
void ssh_socket_fd_set(ssh_socket s, fd_set *set, socket_t *max_fd);
|
void ssh_socket_fd_set(ssh_socket s, fd_set *set, socket_t *max_fd);
|
||||||
@@ -63,6 +64,9 @@ void ssh_socket_set_callbacks(ssh_socket s, ssh_socket_callbacks callbacks);
|
|||||||
int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, socket_t fd, int revents, void *v_s);
|
int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, socket_t fd, int revents, void *v_s);
|
||||||
struct ssh_poll_handle_struct * ssh_socket_get_poll_handle(ssh_socket s);
|
struct ssh_poll_handle_struct * ssh_socket_get_poll_handle(ssh_socket s);
|
||||||
|
|
||||||
int ssh_socket_connect(ssh_socket s, const char *host, int port, const char *bind_addr);
|
int ssh_socket_connect(ssh_socket s,
|
||||||
|
const char *host,
|
||||||
|
uint16_t port,
|
||||||
|
const char *bind_addr);
|
||||||
|
|
||||||
#endif /* SOCKET_H_ */
|
#endif /* SOCKET_H_ */
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
#define STRING_H_
|
#define STRING_H_
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* must be 32 bits number + immediately our data */
|
/* must be 32 bits number + immediately our data */
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
@@ -38,4 +42,8 @@ __attribute__ ((packed))
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* STRING_H_ */
|
#endif /* STRING_H_ */
|
||||||
|
|||||||
@@ -49,6 +49,10 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
int ssh_threads_init(void);
|
int ssh_threads_init(void);
|
||||||
void ssh_threads_finalize(void);
|
void ssh_threads_finalize(void);
|
||||||
const char *ssh_threads_get_type(void);
|
const char *ssh_threads_get_type(void);
|
||||||
@@ -60,4 +64,8 @@ struct ssh_threads_callbacks_struct *ssh_threads_get_default(void);
|
|||||||
int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks);
|
int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks);
|
||||||
void crypto_thread_finalize(void);
|
void crypto_thread_finalize(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* THREADS_H_ */
|
#endif /* THREADS_H_ */
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ struct ssh_tokens_st {
|
|||||||
char **tokens;
|
char **tokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ssh_tokens_st *ssh_tokenize(const char *chain, char separator);
|
struct ssh_tokens_st *ssh_tokenize(const char *chain, char separator);
|
||||||
|
|
||||||
void ssh_tokens_free(struct ssh_tokens_st *tokens);
|
void ssh_tokens_free(struct ssh_tokens_st *tokens);
|
||||||
@@ -45,4 +49,8 @@ char *ssh_remove_duplicates(const char *list);
|
|||||||
|
|
||||||
char *ssh_append_without_duplicates(const char *list,
|
char *ssh_append_without_duplicates(const char *list,
|
||||||
const char *appended_list);
|
const char *appended_list);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* TOKEN_H_ */
|
#endif /* TOKEN_H_ */
|
||||||
|
|||||||
@@ -29,6 +29,10 @@
|
|||||||
#include "libssh/libgcrypt.h"
|
#include "libssh/libgcrypt.h"
|
||||||
#include "libssh/libmbedcrypto.h"
|
#include "libssh/libmbedcrypto.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
enum ssh_kdf_digest {
|
enum ssh_kdf_digest {
|
||||||
SSH_KDF_SHA1=1,
|
SSH_KDF_SHA1=1,
|
||||||
SSH_KDF_SHA256,
|
SSH_KDF_SHA256,
|
||||||
@@ -42,7 +46,8 @@ enum ssh_hmac_e {
|
|||||||
SSH_HMAC_SHA512,
|
SSH_HMAC_SHA512,
|
||||||
SSH_HMAC_MD5,
|
SSH_HMAC_MD5,
|
||||||
SSH_HMAC_AEAD_POLY1305,
|
SSH_HMAC_AEAD_POLY1305,
|
||||||
SSH_HMAC_AEAD_GCM
|
SSH_HMAC_AEAD_GCM,
|
||||||
|
SSH_HMAC_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ssh_des_e {
|
enum ssh_des_e {
|
||||||
@@ -67,42 +72,42 @@ struct ssh_crypto_struct;
|
|||||||
|
|
||||||
typedef struct ssh_mac_ctx_struct *ssh_mac_ctx;
|
typedef struct ssh_mac_ctx_struct *ssh_mac_ctx;
|
||||||
MD5CTX md5_init(void);
|
MD5CTX md5_init(void);
|
||||||
void md5_update(MD5CTX c, const void *data, unsigned long len);
|
void md5_ctx_free(MD5CTX);
|
||||||
void md5_final(unsigned char *md,MD5CTX c);
|
int md5_update(MD5CTX c, const void *data, size_t len);
|
||||||
|
int md5_final(unsigned char *md, MD5CTX c);
|
||||||
|
|
||||||
SHACTX sha1_init(void);
|
SHACTX sha1_init(void);
|
||||||
void sha1_update(SHACTX c, const void *data, unsigned long len);
|
void sha1_ctx_free(SHACTX);
|
||||||
void sha1_final(unsigned char *md,SHACTX c);
|
int sha1_update(SHACTX c, const void *data, size_t len);
|
||||||
void sha1(const unsigned char *digest,int len,unsigned char *hash);
|
int sha1_final(unsigned char *md,SHACTX c);
|
||||||
|
int sha1(const unsigned char *digest,size_t len, unsigned char *hash);
|
||||||
|
|
||||||
SHA256CTX sha256_init(void);
|
SHA256CTX sha256_init(void);
|
||||||
void sha256_update(SHA256CTX c, const void *data, unsigned long len);
|
void sha256_ctx_free(SHA256CTX);
|
||||||
void sha256_final(unsigned char *md,SHA256CTX c);
|
int sha256_update(SHA256CTX c, const void *data, size_t len);
|
||||||
void sha256(const unsigned char *digest, int len, unsigned char *hash);
|
int sha256_final(unsigned char *md,SHA256CTX c);
|
||||||
|
int sha256(const unsigned char *digest, size_t len, unsigned char *hash);
|
||||||
|
|
||||||
SHA384CTX sha384_init(void);
|
SHA384CTX sha384_init(void);
|
||||||
void sha384_update(SHA384CTX c, const void *data, unsigned long len);
|
void sha384_ctx_free(SHA384CTX);
|
||||||
void sha384_final(unsigned char *md,SHA384CTX c);
|
int sha384_update(SHA384CTX c, const void *data, size_t len);
|
||||||
void sha384(const unsigned char *digest, int len, unsigned char *hash);
|
int sha384_final(unsigned char *md,SHA384CTX c);
|
||||||
|
int sha384(const unsigned char *digest, size_t len, unsigned char *hash);
|
||||||
|
|
||||||
SHA512CTX sha512_init(void);
|
SHA512CTX sha512_init(void);
|
||||||
void sha512_update(SHA512CTX c, const void *data, unsigned long len);
|
void sha512_ctx_free(SHA512CTX);
|
||||||
void sha512_final(unsigned char *md,SHA512CTX c);
|
int sha512_update(SHA512CTX c, const void *data, size_t len);
|
||||||
void sha512(const unsigned char *digest, int len, unsigned char *hash);
|
int sha512_final(unsigned char *md,SHA512CTX c);
|
||||||
|
int sha512(const unsigned char *digest, size_t len, unsigned char *hash);
|
||||||
|
|
||||||
void evp(int nid, unsigned char *digest, int len, unsigned char *hash, unsigned int *hlen);
|
HMACCTX hmac_init(const void *key,size_t len, enum ssh_hmac_e type);
|
||||||
EVPCTX evp_init(int nid);
|
int hmac_update(HMACCTX c, const void *data, size_t len);
|
||||||
void evp_update(EVPCTX ctx, const void *data, unsigned long len);
|
int hmac_final(HMACCTX ctx, unsigned char *hashmacbuf, size_t *len);
|
||||||
void evp_final(EVPCTX ctx, unsigned char *md, unsigned int *mdlen);
|
|
||||||
|
|
||||||
HMACCTX hmac_init(const void *key,int len, enum ssh_hmac_e type);
|
|
||||||
void hmac_update(HMACCTX c, const void *data, unsigned long len);
|
|
||||||
void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
|
|
||||||
size_t hmac_digest_len(enum ssh_hmac_e type);
|
size_t hmac_digest_len(enum ssh_hmac_e type);
|
||||||
|
|
||||||
int ssh_kdf(struct ssh_crypto_struct *crypto,
|
int ssh_kdf(struct ssh_crypto_struct *crypto,
|
||||||
unsigned char *key, size_t key_len,
|
unsigned char *key, size_t key_len,
|
||||||
int key_type, unsigned char *output,
|
uint8_t key_type, unsigned char *output,
|
||||||
size_t requested_len);
|
size_t requested_len);
|
||||||
|
|
||||||
int crypt_set_algorithms_client(ssh_session session);
|
int crypt_set_algorithms_client(ssh_session session);
|
||||||
@@ -119,4 +124,15 @@ struct ssh_hmac_struct *ssh_get_hmactab(void);
|
|||||||
struct ssh_cipher_struct *ssh_get_ciphertab(void);
|
struct ssh_cipher_struct *ssh_get_ciphertab(void);
|
||||||
const char *ssh_hmac_type_to_string(enum ssh_hmac_e hmac_type, bool etm);
|
const char *ssh_hmac_type_to_string(enum ssh_hmac_e hmac_type, bool etm);
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBCRYPTO) && OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||||
|
int evp_build_pkey(const char* name, OSSL_PARAM_BLD *param_bld, EVP_PKEY **pkey, int selection);
|
||||||
|
int evp_dup_dsa_pkey(const ssh_key key, ssh_key new_key, int demote);
|
||||||
|
int evp_dup_rsa_pkey(const ssh_key key, ssh_key new_key, int demote);
|
||||||
|
int evp_dup_ecdsa_pkey(const ssh_key key, ssh_key new_key, int demote);
|
||||||
|
#endif /* HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* WRAPPER_H_ */
|
#endif /* WRAPPER_H_ */
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user