putty-key 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGES.md +16 -0
  5. data/Gemfile +0 -6
  6. data/LICENSE +1 -1
  7. data/README.md +32 -6
  8. data/Rakefile +24 -0
  9. data/lib/putty/key.rb +6 -6
  10. data/lib/putty/key/argon2_params.rb +101 -0
  11. data/lib/putty/key/error.rb +17 -0
  12. data/lib/putty/key/libargon2.rb +54 -0
  13. data/lib/putty/key/ppk.rb +469 -103
  14. data/lib/putty/key/util.rb +10 -10
  15. data/lib/putty/key/version.rb +1 -1
  16. data/putty-key.gemspec +11 -2
  17. data/test/argon2_params_test.rb +144 -0
  18. data/test/fixtures/{dss-1024-encrypted.ppk → dss-1024-encrypted-format-2.ppk} +17 -17
  19. data/test/fixtures/dss-1024-encrypted-format-3.ppk +22 -0
  20. data/test/fixtures/{dss-1024.ppk → dss-1024-format-2.ppk} +17 -17
  21. data/test/fixtures/dss-1024-format-3.ppk +17 -0
  22. data/test/fixtures/{ecdsa-sha2-nistp256-encrypted.ppk → ecdsa-sha2-nistp256-encrypted-format-2.ppk} +10 -10
  23. data/test/fixtures/ecdsa-sha2-nistp256-encrypted-format-3.ppk +15 -0
  24. data/test/fixtures/{ecdsa-sha2-nistp256.ppk → ecdsa-sha2-nistp256-format-2.ppk} +10 -10
  25. data/test/fixtures/ecdsa-sha2-nistp256-format-3.ppk +10 -0
  26. data/test/fixtures/{ecdsa-sha2-nistp384-encrypted.ppk → ecdsa-sha2-nistp384-encrypted-format-2.ppk} +11 -11
  27. data/test/fixtures/ecdsa-sha2-nistp384-encrypted-format-3.ppk +16 -0
  28. data/test/fixtures/{ecdsa-sha2-nistp384.ppk → ecdsa-sha2-nistp384-format-2.ppk} +11 -11
  29. data/test/fixtures/ecdsa-sha2-nistp384-format-3.ppk +11 -0
  30. data/test/fixtures/{ecdsa-sha2-nistp521-encrypted.ppk → ecdsa-sha2-nistp521-encrypted-format-2.ppk} +12 -12
  31. data/test/fixtures/ecdsa-sha2-nistp521-encrypted-format-3.ppk +17 -0
  32. data/test/fixtures/{ecdsa-sha2-nistp521.ppk → ecdsa-sha2-nistp521-format-2.ppk} +12 -12
  33. data/test/fixtures/ecdsa-sha2-nistp521-format-3.ppk +12 -0
  34. data/test/fixtures/{rsa-2048-encrypted.ppk → rsa-2048-encrypted-format-2.ppk} +26 -26
  35. data/test/fixtures/rsa-2048-encrypted-format-3.ppk +31 -0
  36. data/test/fixtures/{rsa-2048.ppk → rsa-2048-format-2.ppk} +26 -26
  37. data/test/fixtures/rsa-2048-format-3.ppk +26 -0
  38. data/test/fixtures/test-blank-comment.ppk +11 -11
  39. data/test/fixtures/test-empty-blobs-encrypted.ppk +6 -0
  40. data/test/fixtures/test-empty-blobs.ppk +6 -0
  41. data/test/fixtures/{test-encrypted.ppk → test-encrypted-format-2.ppk} +11 -11
  42. data/test/fixtures/test-encrypted-format-3.ppk +16 -0
  43. data/test/fixtures/test-encrypted-type-d-format-3.ppk +16 -0
  44. data/test/fixtures/test-encrypted-type-i-format-3.ppk +16 -0
  45. data/test/fixtures/{test-unix-line-endings.ppk → test-format-2.ppk} +0 -0
  46. data/test/fixtures/test-format-3.ppk +11 -0
  47. data/test/fixtures/test-invalid-argon2-memory-for-libargon2.ppk +16 -0
  48. data/test/fixtures/test-invalid-argon2-memory-maximum.ppk +16 -0
  49. data/test/fixtures/test-invalid-argon2-memory.ppk +16 -0
  50. data/test/fixtures/test-invalid-argon2-parallelism-maximum.ppk +16 -0
  51. data/test/fixtures/test-invalid-argon2-parallelism.ppk +16 -0
  52. data/test/fixtures/test-invalid-argon2-passes-maximum.ppk +16 -0
  53. data/test/fixtures/test-invalid-argon2-passes.ppk +16 -0
  54. data/test/fixtures/test-invalid-argon2-salt.ppk +16 -0
  55. data/test/fixtures/test-invalid-blob-lines.ppk +11 -11
  56. data/test/fixtures/test-invalid-encryption-type.ppk +11 -11
  57. data/test/fixtures/test-invalid-format-1.ppk +11 -11
  58. data/test/fixtures/{test-invalid-format-3.ppk → test-invalid-format-4.ppk} +11 -11
  59. data/test/fixtures/test-invalid-key-derivation.ppk +16 -0
  60. data/test/fixtures/test-invalid-private-mac.ppk +11 -11
  61. data/test/fixtures/test-legacy-mac-line-endings.ppk +1 -0
  62. data/test/fixtures/test-missing-final-line-ending.ppk +11 -0
  63. data/test/fixtures/test-truncated.ppk +10 -10
  64. data/test/fixtures/{test.ppk → test-windows-line-endings.ppk} +0 -0
  65. data/test/openssl_test.rb +243 -53
  66. data/test/ppk_test.rb +325 -44
  67. metadata +73 -23
  68. metadata.gz.sig +0 -0
@@ -0,0 +1,16 @@
1
+ PuTTY-User-Key-File-3: test
2
+ Encryption: aes256-cbc
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Key-Derivation: Argon2id
8
+ Argon2-Memory: -1
9
+ Argon2-Passes: 8
10
+ Argon2-Parallelism: 1
11
+ Argon2-Salt: 7d5d4557c5563a5b5009e1452c518e04
12
+ Private-Lines: 3
13
+ sdvJ5Ayw1iLf2fMiWnybD27Ms6uPJTtBPhGvfCsk3IX9i9QJ4kItn6lzVndmgWi3
14
+ aCH2aS4YL+MjYYc4PWXQfN+3PJ8NVVdtopPTr3qplc0hDeURz8Y0pyr1zIneTLeJ
15
+ 0DHmIlqiI2v8N54RGaatxi0H9EYWbjCGG/SiRjjOM/EcaJ8rngXXhkQHbV2L7kxO
16
+ Private-MAC: 5f6f45b0576b1d8be8af871873d66ff4d59d9eeef05459176e521ebcb931c0ea
@@ -0,0 +1,16 @@
1
+ PuTTY-User-Key-File-3: test
2
+ Encryption: aes256-cbc
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Key-Derivation: Argon2id
8
+ Argon2-Memory: 8192
9
+ Argon2-Passes: 8
10
+ Argon2-Parallelism: 4294967297
11
+ Argon2-Salt: 7d5d4557c5563a5b5009e1452c518e04
12
+ Private-Lines: 3
13
+ sdvJ5Ayw1iLf2fMiWnybD27Ms6uPJTtBPhGvfCsk3IX9i9QJ4kItn6lzVndmgWi3
14
+ aCH2aS4YL+MjYYc4PWXQfN+3PJ8NVVdtopPTr3qplc0hDeURz8Y0pyr1zIneTLeJ
15
+ 0DHmIlqiI2v8N54RGaatxi0H9EYWbjCGG/SiRjjOM/EcaJ8rngXXhkQHbV2L7kxO
16
+ Private-MAC: 5f6f45b0576b1d8be8af871873d66ff4d59d9eeef05459176e521ebcb931c0ea
@@ -0,0 +1,16 @@
1
+ PuTTY-User-Key-File-3: test
2
+ Encryption: aes256-cbc
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Key-Derivation: Argon2id
8
+ Argon2-Memory: 8192
9
+ Argon2-Passes: 8
10
+ Argon2-Parallelism: -1
11
+ Argon2-Salt: 7d5d4557c5563a5b5009e1452c518e04
12
+ Private-Lines: 3
13
+ sdvJ5Ayw1iLf2fMiWnybD27Ms6uPJTtBPhGvfCsk3IX9i9QJ4kItn6lzVndmgWi3
14
+ aCH2aS4YL+MjYYc4PWXQfN+3PJ8NVVdtopPTr3qplc0hDeURz8Y0pyr1zIneTLeJ
15
+ 0DHmIlqiI2v8N54RGaatxi0H9EYWbjCGG/SiRjjOM/EcaJ8rngXXhkQHbV2L7kxO
16
+ Private-MAC: 5f6f45b0576b1d8be8af871873d66ff4d59d9eeef05459176e521ebcb931c0ea
@@ -0,0 +1,16 @@
1
+ PuTTY-User-Key-File-3: test
2
+ Encryption: aes256-cbc
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Key-Derivation: Argon2id
8
+ Argon2-Memory: 8192
9
+ Argon2-Passes: 4294967297
10
+ Argon2-Parallelism: 1
11
+ Argon2-Salt: 7d5d4557c5563a5b5009e1452c518e04
12
+ Private-Lines: 3
13
+ sdvJ5Ayw1iLf2fMiWnybD27Ms6uPJTtBPhGvfCsk3IX9i9QJ4kItn6lzVndmgWi3
14
+ aCH2aS4YL+MjYYc4PWXQfN+3PJ8NVVdtopPTr3qplc0hDeURz8Y0pyr1zIneTLeJ
15
+ 0DHmIlqiI2v8N54RGaatxi0H9EYWbjCGG/SiRjjOM/EcaJ8rngXXhkQHbV2L7kxO
16
+ Private-MAC: 5f6f45b0576b1d8be8af871873d66ff4d59d9eeef05459176e521ebcb931c0ea
@@ -0,0 +1,16 @@
1
+ PuTTY-User-Key-File-3: test
2
+ Encryption: aes256-cbc
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Key-Derivation: Argon2id
8
+ Argon2-Memory: 8192
9
+ Argon2-Passes: -1
10
+ Argon2-Parallelism: 1
11
+ Argon2-Salt: 7d5d4557c5563a5b5009e1452c518e04
12
+ Private-Lines: 3
13
+ sdvJ5Ayw1iLf2fMiWnybD27Ms6uPJTtBPhGvfCsk3IX9i9QJ4kItn6lzVndmgWi3
14
+ aCH2aS4YL+MjYYc4PWXQfN+3PJ8NVVdtopPTr3qplc0hDeURz8Y0pyr1zIneTLeJ
15
+ 0DHmIlqiI2v8N54RGaatxi0H9EYWbjCGG/SiRjjOM/EcaJ8rngXXhkQHbV2L7kxO
16
+ Private-MAC: 5f6f45b0576b1d8be8af871873d66ff4d59d9eeef05459176e521ebcb931c0ea
@@ -0,0 +1,16 @@
1
+ PuTTY-User-Key-File-3: test
2
+ Encryption: aes256-cbc
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Key-Derivation: Argon2id
8
+ Argon2-Memory: 8192
9
+ Argon2-Passes: 8
10
+ Argon2-Parallelism: 1
11
+ Argon2-Salt: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
12
+ Private-Lines: 3
13
+ sdvJ5Ayw1iLf2fMiWnybD27Ms6uPJTtBPhGvfCsk3IX9i9QJ4kItn6lzVndmgWi3
14
+ aCH2aS4YL+MjYYc4PWXQfN+3PJ8NVVdtopPTr3qplc0hDeURz8Y0pyr1zIneTLeJ
15
+ 0DHmIlqiI2v8N54RGaatxi0H9EYWbjCGG/SiRjjOM/EcaJ8rngXXhkQHbV2L7kxO
16
+ Private-MAC: 5f6f45b0576b1d8be8af871873d66ff4d59d9eeef05459176e521ebcb931c0ea
@@ -1,11 +1,11 @@
1
- PuTTY-User-Key-File-2: test
2
- Encryption: none
3
- Comment: This is a test ppk file
4
- Public-Lines: -2
5
- AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
- aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
- Private-Lines: 3
8
- AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
- YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
- b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
- Private-MAC: f3045e1abe1fd459117eec9d0eed18661b4274bb
1
+ PuTTY-User-Key-File-2: test
2
+ Encryption: none
3
+ Comment: This is a test ppk file
4
+ Public-Lines: -2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Private-Lines: 3
8
+ AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
+ YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
+ b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
+ Private-MAC: f3045e1abe1fd459117eec9d0eed18661b4274bb
@@ -1,11 +1,11 @@
1
- PuTTY-User-Key-File-2: test
2
- Encryption: camellia256-cbc
3
- Comment: This is a test ppk file
4
- Public-Lines: 2
5
- AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
- aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
- Private-Lines: 3
8
- O4jfhfwamnLbbSs/DxTd+nZNFRcBC2XuPBD8VbSRNmLpx57FGVPiLvgYH5Ot8zhb
9
- +90J6pY2hO6M2bQsQNoqMwDB0K/0bSG3ignWN4XKXJOofpmn2o8gBv7xfmJ++2Ni
10
- qAdfPt1qZXIb7Yp4weFQiAWJ6m0ysDIS7Xnwv/uZLRc=
11
- Private-MAC: 435b5081a0f34cee896e0783db15e9e832a9de31
1
+ PuTTY-User-Key-File-2: test
2
+ Encryption: camellia256-cbc
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Private-Lines: 3
8
+ O4jfhfwamnLbbSs/DxTd+nZNFRcBC2XuPBD8VbSRNmLpx57FGVPiLvgYH5Ot8zhb
9
+ +90J6pY2hO6M2bQsQNoqMwDB0K/0bSG3ignWN4XKXJOofpmn2o8gBv7xfmJ++2Ni
10
+ qAdfPt1qZXIb7Yp4weFQiAWJ6m0ysDIS7Xnwv/uZLRc=
11
+ Private-MAC: 435b5081a0f34cee896e0783db15e9e832a9de31
@@ -1,11 +1,11 @@
1
- PuTTY-User-Key-File-1: test
2
- Encryption: none
3
- Comment: This is a test ppk file
4
- Public-Lines: 2
5
- AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
- aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
- Private-Lines: 3
8
- AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
- YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
- b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
- Private-MAC: f3045e1abe1fd459117eec9d0eed18661b4274bb
1
+ PuTTY-User-Key-File-1: test
2
+ Encryption: none
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Private-Lines: 3
8
+ AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
+ YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
+ b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
+ Private-MAC: f3045e1abe1fd459117eec9d0eed18661b4274bb
@@ -1,11 +1,11 @@
1
- PuTTY-User-Key-File-3: test
2
- Encryption: none
3
- Comment: This is a test ppk file
4
- Public-Lines: 2
5
- AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
- aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
- Private-Lines: 3
8
- AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
- YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
- b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
- Private-MAC: f3045e1abe1fd459117eec9d0eed18661b4274bb
1
+ PuTTY-User-Key-File-4: test
2
+ Encryption: none
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Private-Lines: 3
8
+ AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
+ YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
+ b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
+ Private-MAC: f3045e1abe1fd459117eec9d0eed18661b4274bb
@@ -0,0 +1,16 @@
1
+ PuTTY-User-Key-File-3: test
2
+ Encryption: aes256-cbc
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Key-Derivation: Argon2x
8
+ Argon2-Memory: 8192
9
+ Argon2-Passes: 8
10
+ Argon2-Parallelism: 1
11
+ Argon2-Salt: 7d5d4557c5563a5b5009e1452c518e04
12
+ Private-Lines: 3
13
+ sdvJ5Ayw1iLf2fMiWnybD27Ms6uPJTtBPhGvfCsk3IX9i9QJ4kItn6lzVndmgWi3
14
+ aCH2aS4YL+MjYYc4PWXQfN+3PJ8NVVdtopPTr3qplc0hDeURz8Y0pyr1zIneTLeJ
15
+ 0DHmIlqiI2v8N54RGaatxi0H9EYWbjCGG/SiRjjOM/EcaJ8rngXXhkQHbV2L7kxO
16
+ Private-MAC: 5f6f45b0576b1d8be8af871873d66ff4d59d9eeef05459176e521ebcb931c0ea
@@ -1,11 +1,11 @@
1
- PuTTY-User-Key-File-2: test
2
- Encryption: none
3
- Comment: This is a test ppk file
4
- Public-Lines: 2
5
- AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
- aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
- Private-Lines: 3
8
- AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
- YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
- b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
- Private-MAC: a89e0b76bb00232fd21871875bcd319cff3116ea
1
+ PuTTY-User-Key-File-2: test
2
+ Encryption: none
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Private-Lines: 3
8
+ AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
+ YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
+ b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
+ Private-MAC: a89e0b76bb00232fd21871875bcd319cff3116ea
@@ -0,0 +1 @@
1
+ PuTTY-User-Key-File-2: test
@@ -0,0 +1,11 @@
1
+ PuTTY-User-Key-File-2: test
2
+ Encryption: none
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Private-Lines: 3
8
+ AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
+ YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
+ b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
11
+ Private-MAC: f3045e1abe1fd459117eec9d0eed18661b4274bb
@@ -1,10 +1,10 @@
1
- PuTTY-User-Key-File-2: test
2
- Encryption: none
3
- Comment: This is a test ppk file
4
- Public-Lines: 2
5
- AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
- aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
- Private-Lines: 3
8
- AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
- YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
- b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
1
+ PuTTY-User-Key-File-2: test
2
+ Encryption: none
3
+ Comment: This is a test ppk file
4
+ Public-Lines: 2
5
+ AAAABHRlc3QAAABKVGhpcyBpcyB0aGUgcHVibGljIGJsb2IgZnJvbSBhIHBwayBm
6
+ aWxlIGNyZWF0ZWQgZm9yIHRlc3RpbmcgcHVycG9zZXMgb25seS4=
7
+ Private-Lines: 3
8
+ AAAAd1RoaXMgaXMgdGhlIHByaXZhdGUgYmxvYiBmcm9tIGEgcHBrIGZpbGUgY3Jl
9
+ YXRlZCBmb3IgdGVzdGluZyBwdXJwb3NlcyBvbmx5LiBJdCBpcyBzbGlnaHRseSBs
10
+ b25nZXIgdGhhbiB0aGUgcHVibGljIGJsb2Iu
data/test/openssl_test.rb CHANGED
@@ -12,33 +12,61 @@ class OpenSSLTest < Minitest::Test
12
12
  end
13
13
 
14
14
  def test_from_ppk_unsupported_algorithm
15
- ppk = PuTTY::Key::PPK.new(fixture_path('test.ppk'))
15
+ ppk = PuTTY::Key::PPK.new(fixture_path('test-format-2.ppk'))
16
16
  assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
17
17
  end
18
18
 
19
- def test_from_ppk_rsa
20
- ppk = PuTTY::Key::PPK.new(fixture_path('rsa-2048.ppk'))
19
+ def test_from_ppk_rsa_format_2
20
+ ppk = PuTTY::Key::PPK.new(fixture_path('rsa-2048-format-2.ppk'))
21
21
  pkey = OpenSSL::PKey.from_ppk(ppk)
22
22
  assert_kind_of(OpenSSL::PKey::RSA, pkey)
23
23
  assert_equal(normalize_pem_fixture('rsa-2048.pem'), pkey.to_pem)
24
24
  end
25
25
 
26
- def test_from_ppk_rsa_encrypted
27
- ppk = PuTTY::Key::PPK.new(fixture_path('rsa-2048-encrypted.ppk'), 'Test Passphrase')
26
+ def test_from_ppk_rsa_encrypted_format_2
27
+ ppk = PuTTY::Key::PPK.new(fixture_path('rsa-2048-encrypted-format-2.ppk'), 'Test Passphrase')
28
28
  pkey = OpenSSL::PKey.from_ppk(ppk)
29
29
  assert_kind_of(OpenSSL::PKey::RSA, pkey)
30
30
  assert_equal(normalize_pem_fixture('rsa-2048.pem'), pkey.to_pem)
31
31
  end
32
32
 
33
- def test_from_ppk_dss
34
- ppk = PuTTY::Key::PPK.new(fixture_path('dss-1024.ppk'))
33
+ def test_from_ppk_rsa_format_3
34
+ ppk = PuTTY::Key::PPK.new(fixture_path('rsa-2048-format-3.ppk'))
35
+ pkey = OpenSSL::PKey.from_ppk(ppk)
36
+ assert_kind_of(OpenSSL::PKey::RSA, pkey)
37
+ assert_equal(normalize_pem_fixture('rsa-2048.pem'), pkey.to_pem)
38
+ end
39
+
40
+ def test_from_ppk_rsa_encrypted_format_3
41
+ ppk = PuTTY::Key::PPK.new(fixture_path('rsa-2048-encrypted-format-3.ppk'), 'Test Passphrase')
42
+ pkey = OpenSSL::PKey.from_ppk(ppk)
43
+ assert_kind_of(OpenSSL::PKey::RSA, pkey)
44
+ assert_equal(normalize_pem_fixture('rsa-2048.pem'), pkey.to_pem)
45
+ end
46
+
47
+ def test_from_ppk_dss_format_2
48
+ ppk = PuTTY::Key::PPK.new(fixture_path('dss-1024-format-2.ppk'))
49
+ pkey = OpenSSL::PKey.from_ppk(ppk)
50
+ assert_kind_of(OpenSSL::PKey::DSA, pkey)
51
+ assert_equal(normalize_pem_fixture('dss-1024.pem'), pkey.to_pem)
52
+ end
53
+
54
+ def test_from_ppk_dss_encrypted_format_2
55
+ ppk = PuTTY::Key::PPK.new(fixture_path('dss-1024-encrypted-format-2.ppk'), 'Test Passphrase')
56
+ pkey = OpenSSL::PKey.from_ppk(ppk)
57
+ assert_kind_of(OpenSSL::PKey::DSA, pkey)
58
+ assert_equal(normalize_pem_fixture('dss-1024.pem'), pkey.to_pem)
59
+ end
60
+
61
+ def test_from_ppk_dss_format_3
62
+ ppk = PuTTY::Key::PPK.new(fixture_path('dss-1024-format-3.ppk'))
35
63
  pkey = OpenSSL::PKey.from_ppk(ppk)
36
64
  assert_kind_of(OpenSSL::PKey::DSA, pkey)
37
65
  assert_equal(normalize_pem_fixture('dss-1024.pem'), pkey.to_pem)
38
66
  end
39
67
 
40
- def test_from_ppk_dss_encrypted
41
- ppk = PuTTY::Key::PPK.new(fixture_path('dss-1024-encrypted.ppk'), 'Test Passphrase')
68
+ def test_from_ppk_dss_encrypted_format_3
69
+ ppk = PuTTY::Key::PPK.new(fixture_path('dss-1024-encrypted-format-3.ppk'), 'Test Passphrase')
42
70
  pkey = OpenSSL::PKey.from_ppk(ppk)
43
71
  assert_kind_of(OpenSSL::PKey::DSA, pkey)
44
72
  assert_equal(normalize_pem_fixture('dss-1024.pem'), pkey.to_pem)
@@ -46,75 +74,147 @@ class OpenSSLTest < Minitest::Test
46
74
 
47
75
  # Old versions of jruby-openssl don't include an EC class (version 0.9.16).
48
76
  if defined?(OpenSSL::PKey::EC)
49
- def test_from_ppk_ecdsa_sha2_nistp256
50
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256.ppk'))
77
+ def test_from_ppk_ecdsa_sha2_nistp256_format_2
78
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-format-2.ppk'))
79
+ pkey = OpenSSL::PKey.from_ppk(ppk)
80
+ assert_kind_of(OpenSSL::PKey::EC, pkey)
81
+ assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp256.pem', OpenSSL::PKey::EC), pkey.to_pem)
82
+ end
83
+
84
+ def test_from_ppk_ecdsa_sha2_nistp256_encrypted_format_2
85
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-encrypted-format-2.ppk'), 'Test Passphrase')
86
+ pkey = OpenSSL::PKey.from_ppk(ppk)
87
+ assert_kind_of(OpenSSL::PKey::EC, pkey)
88
+ assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp256.pem', OpenSSL::PKey::EC), pkey.to_pem)
89
+ end
90
+
91
+ def test_from_ppk_ecdsa_sha2_nistp256_format_3
92
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-format-3.ppk'))
51
93
  pkey = OpenSSL::PKey.from_ppk(ppk)
52
94
  assert_kind_of(OpenSSL::PKey::EC, pkey)
53
95
  assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp256.pem', OpenSSL::PKey::EC), pkey.to_pem)
54
96
  end
55
97
 
56
- def test_from_ppk_ecdsa_sha2_nistp256_encrypted
57
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-encrypted.ppk'), 'Test Passphrase')
98
+ def test_from_ppk_ecdsa_sha2_nistp256_encrypted_format_3
99
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-encrypted-format-3.ppk'), 'Test Passphrase')
58
100
  pkey = OpenSSL::PKey.from_ppk(ppk)
59
101
  assert_kind_of(OpenSSL::PKey::EC, pkey)
60
102
  assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp256.pem', OpenSSL::PKey::EC), pkey.to_pem)
61
103
  end
62
104
 
63
- def test_from_ppk_ecdsa_sha2_nistp384
64
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384.ppk'))
105
+ def test_from_ppk_ecdsa_sha2_nistp384_format_2
106
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-format-2.ppk'))
107
+ pkey = OpenSSL::PKey.from_ppk(ppk)
108
+ assert_kind_of(OpenSSL::PKey::EC, pkey)
109
+ assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp384.pem', OpenSSL::PKey::EC), pkey.to_pem)
110
+ end
111
+
112
+ def test_from_ppk_ecdsa_sha2_nistp384_encrypted_format_2
113
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-encrypted-format-2.ppk'), 'Test Passphrase')
114
+ pkey = OpenSSL::PKey.from_ppk(ppk)
115
+ assert_kind_of(OpenSSL::PKey::EC, pkey)
116
+ assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp384.pem', OpenSSL::PKey::EC), pkey.to_pem)
117
+ end
118
+
119
+ def test_from_ppk_ecdsa_sha2_nistp384_format_3
120
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-format-3.ppk'))
65
121
  pkey = OpenSSL::PKey.from_ppk(ppk)
66
122
  assert_kind_of(OpenSSL::PKey::EC, pkey)
67
123
  assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp384.pem', OpenSSL::PKey::EC), pkey.to_pem)
68
124
  end
69
125
 
70
- def test_from_ppk_ecdsa_sha2_nistp384_encrypted
71
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-encrypted.ppk'), 'Test Passphrase')
126
+ def test_from_ppk_ecdsa_sha2_nistp384_encrypted_format_3
127
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-encrypted-format-3.ppk'), 'Test Passphrase')
72
128
  pkey = OpenSSL::PKey.from_ppk(ppk)
73
129
  assert_kind_of(OpenSSL::PKey::EC, pkey)
74
130
  assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp384.pem', OpenSSL::PKey::EC), pkey.to_pem)
75
131
  end
76
132
 
77
- def test_from_ppk_ecdsa_sha2_nistp521
78
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521.ppk'))
133
+ def test_from_ppk_ecdsa_sha2_nistp521_format_2
134
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-format-2.ppk'))
135
+ pkey = OpenSSL::PKey.from_ppk(ppk)
136
+ assert_kind_of(OpenSSL::PKey::EC, pkey)
137
+ assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp521.pem', OpenSSL::PKey::EC), pkey.to_pem)
138
+ end
139
+
140
+ def test_from_ppk_ecdsa_sha2_nistp521_encrypted_format_2
141
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-encrypted-format-2.ppk'), 'Test Passphrase')
142
+ pkey = OpenSSL::PKey.from_ppk(ppk)
143
+ assert_kind_of(OpenSSL::PKey::EC, pkey)
144
+ assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp521.pem', OpenSSL::PKey::EC), pkey.to_pem)
145
+ end
146
+
147
+ def test_from_ppk_ecdsa_sha2_nistp521_format_3
148
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-format-3.ppk'))
79
149
  pkey = OpenSSL::PKey.from_ppk(ppk)
80
150
  assert_kind_of(OpenSSL::PKey::EC, pkey)
81
151
  assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp521.pem', OpenSSL::PKey::EC), pkey.to_pem)
82
152
  end
83
153
 
84
- def test_from_ppk_ecdsa_sha2_nistp521_encrypted
85
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-encrypted.ppk'), 'Test Passphrase')
154
+ def test_from_ppk_ecdsa_sha2_nistp521_encrypted_format_3
155
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-encrypted-format-3.ppk'), 'Test Passphrase')
86
156
  pkey = OpenSSL::PKey.from_ppk(ppk)
87
157
  assert_kind_of(OpenSSL::PKey::EC, pkey)
88
158
  assert_equal(normalize_pem_fixture('ecdsa-sha2-nistp521.pem', OpenSSL::PKey::EC), pkey.to_pem)
89
159
  end
90
160
  else
91
- def test_from_ppk_ecdsa_sha2_nistp256
92
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256.ppk'))
161
+ def test_from_ppk_ecdsa_sha2_nistp256_format_2
162
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-format-2.ppk'))
163
+ assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
164
+ end
165
+
166
+ def test_from_ppk_ecdsa_sha2_nistp256_encrypted_format_2
167
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-encrypted-format-2.ppk'), 'Test Passphrase')
168
+ assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
169
+ end
170
+
171
+ def test_from_ppk_ecdsa_sha2_nistp256_format_3
172
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-format-3.ppk'))
173
+ assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
174
+ end
175
+
176
+ def test_from_ppk_ecdsa_sha2_nistp256_encrypted_format_3
177
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-encrypted-format-3.ppk'), 'Test Passphrase')
178
+ assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
179
+ end
180
+
181
+ def test_from_ppk_ecdsa_sha2_nistp384_format_2
182
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-format-2.ppk'))
183
+ assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
184
+ end
185
+
186
+ def test_from_ppk_ecdsa_sha2_nistp384_encrypted_format_2
187
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-encrypted-format-2.ppk'), 'Test Passphrase')
188
+ assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
189
+ end
190
+
191
+ def test_from_ppk_ecdsa_sha2_nistp384_format_3
192
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-format-3.ppk'))
93
193
  assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
94
194
  end
95
195
 
96
- def test_from_ppk_ecdsa_sha2_nistp256_encrypted
97
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp256-encrypted.ppk'), 'Test Passphrase')
196
+ def test_from_ppk_ecdsa_sha2_nistp384_encrypted_format_3
197
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-encrypted-format-3.ppk'), 'Test Passphrase')
98
198
  assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
99
199
  end
100
200
 
101
- def test_from_ppk_ecdsa_sha2_nistp384
102
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384.ppk'))
201
+ def test_from_ppk_ecdsa_sha2_nistp521_format_2
202
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-format-2.ppk'))
103
203
  assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
104
204
  end
105
205
 
106
- def test_from_ppk_ecdsa_sha2_nistp384_encrypted
107
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp384-encrypted.ppk'), 'Test Passphrase')
206
+ def test_from_ppk_ecdsa_sha2_nistp521_encrypted_format_2
207
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-encrypted-format-2.ppk'), 'Test Passphrase')
108
208
  assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
109
209
  end
110
210
 
111
- def test_from_ppk_ecdsa_sha2_nistp521
112
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521.ppk'))
211
+ def test_from_ppk_ecdsa_sha2_nistp521_format_3
212
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-format-3.ppk'))
113
213
  assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
114
214
  end
115
215
 
116
- def test_from_ppk_ecdsa_sha2_nistp521_encrypted
117
- ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-encrypted.ppk'), 'Test Passphrase')
216
+ def test_from_ppk_ecdsa_sha2_nistp521_encrypted_format_3
217
+ ppk = PuTTY::Key::PPK.new(fixture_path('ecdsa-sha2-nistp521-encrypted-format-3.ppk'), 'Test Passphrase')
118
218
  assert_raises(ArgumentError) { OpenSSL::PKey.from_ppk(ppk) }
119
219
  end
120
220
  end
@@ -141,21 +241,39 @@ class OpenSSLTest < Minitest::Test
141
241
  pkey.to_pem
142
242
  end
143
243
 
144
- def test_to_ppk_rsa
244
+ def test_to_ppk_rsa_format_2
145
245
  ppk = pem_to_ppk('rsa-2048.pem')
146
246
  ppk.comment = '2048 bit RSA key'
147
247
  temp_file_name do |file|
148
248
  ppk.save(file)
149
- assert_identical_to_fixture('rsa-2048.ppk', file)
249
+ assert_identical_to_fixture('rsa-2048-format-2.ppk', file)
150
250
  end
151
251
  end
152
252
 
153
- def test_to_ppk_rsa_encrypted
253
+ def test_to_ppk_rsa_encrypted_format_2
154
254
  ppk = pem_to_ppk('rsa-2048.pem')
155
255
  ppk.comment = '2048 bit RSA key'
156
256
  temp_file_name do |file|
157
257
  ppk.save(file, 'Test Passphrase')
158
- assert_identical_to_fixture('rsa-2048-encrypted.ppk', file)
258
+ assert_identical_to_fixture('rsa-2048-encrypted-format-2.ppk', file)
259
+ end
260
+ end
261
+
262
+ def test_to_ppk_rsa_format_3
263
+ ppk = pem_to_ppk('rsa-2048.pem')
264
+ ppk.comment = '2048 bit RSA key'
265
+ temp_file_name do |file|
266
+ ppk.save(file, format: 3)
267
+ assert_identical_to_fixture('rsa-2048-format-3.ppk', file)
268
+ end
269
+ end
270
+
271
+ def test_to_ppk_rsa_encrypted_format_3
272
+ ppk = pem_to_ppk('rsa-2048.pem')
273
+ ppk.comment = '2048 bit RSA key'
274
+ temp_file_name do |file|
275
+ ppk.save(file, 'Test Passphrase', format: 3, argon2_params: PuTTY::Key::Argon2Params.new(memory: 16384, parallelism: 2, passes: 14, salt: "\xcc\x2e\xc7\x12\xee\x7e\x17\xbc\x2b\x9e\x3c\x47\xf5\xbb\xb0\x66".b))
276
+ assert_identical_to_fixture('rsa-2048-encrypted-format-3.ppk', file)
159
277
  end
160
278
  end
161
279
 
@@ -164,21 +282,39 @@ class OpenSSLTest < Minitest::Test
164
282
  assert_raises(PuTTY::Key::InvalidStateError) { pkey.to_ppk }
165
283
  end
166
284
 
167
- def test_to_ppk_dss
285
+ def test_to_ppk_dss_format_2
168
286
  ppk = pem_to_ppk('dss-1024.pem')
169
287
  ppk.comment = '1024 bit DSS key'
170
288
  temp_file_name do |file|
171
289
  ppk.save(file)
172
- assert_identical_to_fixture('dss-1024.ppk', file)
290
+ assert_identical_to_fixture('dss-1024-format-2.ppk', file)
173
291
  end
174
292
  end
175
293
 
176
- def test_to_ppk_dss_encrypted
294
+ def test_to_ppk_dss_encrypted_format_2
177
295
  ppk = pem_to_ppk('dss-1024.pem')
178
296
  ppk.comment = '1024 bit DSS key'
179
297
  temp_file_name do |file|
180
298
  ppk.save(file, 'Test Passphrase')
181
- assert_identical_to_fixture('dss-1024-encrypted.ppk', file)
299
+ assert_identical_to_fixture('dss-1024-encrypted-format-2.ppk', file)
300
+ end
301
+ end
302
+
303
+ def test_to_ppk_dss_format_3
304
+ ppk = pem_to_ppk('dss-1024.pem')
305
+ ppk.comment = '1024 bit DSS key'
306
+ temp_file_name do |file|
307
+ ppk.save(file, format: 3)
308
+ assert_identical_to_fixture('dss-1024-format-3.ppk', file)
309
+ end
310
+ end
311
+
312
+ def test_to_ppk_dss_encrypted_format_3
313
+ ppk = pem_to_ppk('dss-1024.pem')
314
+ ppk.comment = '1024 bit DSS key'
315
+ temp_file_name do |file|
316
+ ppk.save(file, 'Test Passphrase', format: 3, argon2_params: PuTTY::Key::Argon2Params.new(passes: 13, salt: "\x1a\x21\x57\x42\xbf\x63\xed\x4e\xef\xed\x21\xdd\x07\x68\x36\x40".b))
317
+ assert_identical_to_fixture('dss-1024-encrypted-format-3.ppk', file)
182
318
  end
183
319
  end
184
320
 
@@ -189,57 +325,111 @@ class OpenSSLTest < Minitest::Test
189
325
 
190
326
  # Old versions of jruby-openssl don't include an EC class (version 0.9.16).
191
327
  if defined?(OpenSSL::PKey::EC)
192
- def test_to_ppk_ecdsa_sha2_nistp256
328
+ def test_to_ppk_ecdsa_sha2_nistp256_format_2
193
329
  ppk = pem_to_ppk('ecdsa-sha2-nistp256.pem', OpenSSL::PKey::EC)
194
330
  ppk.comment = 'ECDSA NIST P-256 Key'
195
331
  temp_file_name do |file|
196
332
  ppk.save(file)
197
- assert_identical_to_fixture('ecdsa-sha2-nistp256.ppk', file)
333
+ assert_identical_to_fixture('ecdsa-sha2-nistp256-format-2.ppk', file)
198
334
  end
199
335
  end
200
336
 
201
- def test_to_ppk_ecdsa_sha2_nistp256_encrypted
337
+ def test_to_ppk_ecdsa_sha2_nistp256_encrypted_format_2
202
338
  ppk = pem_to_ppk('ecdsa-sha2-nistp256.pem', OpenSSL::PKey::EC)
203
339
  ppk.comment = 'ECDSA NIST P-256 Key'
204
340
  temp_file_name do |file|
205
341
  ppk.save(file, 'Test Passphrase')
206
- assert_identical_to_fixture('ecdsa-sha2-nistp256-encrypted.ppk', file)
342
+ assert_identical_to_fixture('ecdsa-sha2-nistp256-encrypted-format-2.ppk', file)
343
+ end
344
+ end
345
+
346
+ def test_to_ppk_ecdsa_sha2_nistp256_format_3
347
+ ppk = pem_to_ppk('ecdsa-sha2-nistp256.pem', OpenSSL::PKey::EC)
348
+ ppk.comment = 'ECDSA NIST P-256 Key'
349
+ temp_file_name do |file|
350
+ ppk.save(file, format: 3)
351
+ assert_identical_to_fixture('ecdsa-sha2-nistp256-format-3.ppk', file)
352
+ end
353
+ end
354
+
355
+ def test_to_ppk_ecdsa_sha2_nistp256_encrypted_format_3
356
+ ppk = pem_to_ppk('ecdsa-sha2-nistp256.pem', OpenSSL::PKey::EC)
357
+ ppk.comment = 'ECDSA NIST P-256 Key'
358
+ temp_file_name do |file|
359
+ ppk.save(file, 'Test Passphrase', format: 3, argon2_params: PuTTY::Key::Argon2Params.new(type: :i, memory: 4096, passes: 12, salt: "\xba\x83\x64\xf0\xda\x7d\x81\x33\xbb\xd5\xf7\x39\x6a\xc2\x80\xf8".b))
360
+ assert_identical_to_fixture('ecdsa-sha2-nistp256-encrypted-format-3.ppk', file)
207
361
  end
208
362
  end
209
363
 
210
- def test_to_ppk_ecdsa_sha2_nistp384
364
+ def test_to_ppk_ecdsa_sha2_nistp384_format_2
211
365
  ppk = pem_to_ppk('ecdsa-sha2-nistp384.pem', OpenSSL::PKey::EC)
212
366
  ppk.comment = 'ECDSA NIST P-384 Key'
213
367
  temp_file_name do |file|
214
368
  ppk.save(file)
215
- assert_identical_to_fixture('ecdsa-sha2-nistp384.ppk', file)
369
+ assert_identical_to_fixture('ecdsa-sha2-nistp384-format-2.ppk', file)
216
370
  end
217
371
  end
218
372
 
219
- def test_to_ppk_ecdsa_sha2_nistp384_encrypted
373
+ def test_to_ppk_ecdsa_sha2_nistp384_encrypted_format_2
220
374
  ppk = pem_to_ppk('ecdsa-sha2-nistp384.pem', OpenSSL::PKey::EC)
221
375
  ppk.comment = 'ECDSA NIST P-384 Key'
222
376
  temp_file_name do |file|
223
377
  ppk.save(file, 'Test Passphrase')
224
- assert_identical_to_fixture('ecdsa-sha2-nistp384-encrypted.ppk', file)
378
+ assert_identical_to_fixture('ecdsa-sha2-nistp384-encrypted-format-2.ppk', file)
379
+ end
380
+ end
381
+
382
+ def test_to_ppk_ecdsa_sha2_nistp384_format_3
383
+ ppk = pem_to_ppk('ecdsa-sha2-nistp384.pem', OpenSSL::PKey::EC)
384
+ ppk.comment = 'ECDSA NIST P-384 Key'
385
+ temp_file_name do |file|
386
+ ppk.save(file, format: 3)
387
+ assert_identical_to_fixture('ecdsa-sha2-nistp384-format-3.ppk', file)
388
+ end
389
+ end
390
+
391
+ def test_to_ppk_ecdsa_sha2_nistp384_encrypted_format_3
392
+ ppk = pem_to_ppk('ecdsa-sha2-nistp384.pem', OpenSSL::PKey::EC)
393
+ ppk.comment = 'ECDSA NIST P-384 Key'
394
+ temp_file_name do |file|
395
+ ppk.save(file, 'Test Passphrase', format: 3, argon2_params: PuTTY::Key::Argon2Params.new(type: :i, parallelism: 2, passes: 6, salt: "\x0e\xe1\x39\x3b\x17\xb1\xc6\xa7\x79\x2f\x13\xcb\x80\x5e\x49\x56".b))
396
+ assert_identical_to_fixture('ecdsa-sha2-nistp384-encrypted-format-3.ppk', file)
225
397
  end
226
398
  end
227
399
 
228
- def test_to_ppk_ecdsa_sha2_nistp521
400
+ def test_to_ppk_ecdsa_sha2_nistp521_format_2
229
401
  ppk = pem_to_ppk('ecdsa-sha2-nistp521.pem', OpenSSL::PKey::EC)
230
402
  ppk.comment = 'ECDSA NIST P-521 Key'
231
403
  temp_file_name do |file|
232
404
  ppk.save(file)
233
- assert_identical_to_fixture('ecdsa-sha2-nistp521.ppk', file)
405
+ assert_identical_to_fixture('ecdsa-sha2-nistp521-format-2.ppk', file)
234
406
  end
235
407
  end
236
408
 
237
- def test_to_ppk_ecdsa_sha2_nistp521_encrypted
409
+ def test_to_ppk_ecdsa_sha2_nistp521_encrypted_format_2
238
410
  ppk = pem_to_ppk('ecdsa-sha2-nistp521.pem', OpenSSL::PKey::EC)
239
411
  ppk.comment = 'ECDSA NIST P-521 Key'
240
412
  temp_file_name do |file|
241
413
  ppk.save(file, 'Test Passphrase')
242
- assert_identical_to_fixture('ecdsa-sha2-nistp521-encrypted.ppk', file)
414
+ assert_identical_to_fixture('ecdsa-sha2-nistp521-encrypted-format-2.ppk', file)
415
+ end
416
+ end
417
+
418
+ def test_to_ppk_ecdsa_sha2_nistp521_format_3
419
+ ppk = pem_to_ppk('ecdsa-sha2-nistp521.pem', OpenSSL::PKey::EC)
420
+ ppk.comment = 'ECDSA NIST P-521 Key'
421
+ temp_file_name do |file|
422
+ ppk.save(file, format: 3)
423
+ assert_identical_to_fixture('ecdsa-sha2-nistp521-format-3.ppk', file)
424
+ end
425
+ end
426
+
427
+ def test_to_ppk_ecdsa_sha2_nistp521_encrypted_format_3
428
+ ppk = pem_to_ppk('ecdsa-sha2-nistp521.pem', OpenSSL::PKey::EC)
429
+ ppk.comment = 'ECDSA NIST P-521 Key'
430
+ temp_file_name do |file|
431
+ ppk.save(file, 'Test Passphrase', format: 3, argon2_params: PuTTY::Key::Argon2Params.new(type: :d, memory: 9220, passes: 13, salt: "\xea\x6c\x6e\xae\x1e\x22\xcb\x94\x49\xf8\x5c\x96\x57\xc2\x91\x57".b))
432
+ assert_identical_to_fixture('ecdsa-sha2-nistp521-encrypted-format-3.ppk', file)
243
433
  end
244
434
  end
245
435