Add support for encrypted ssh keys
This commit is contained in:
27
vendor/github.com/BurntSushi/toml/COPYING
generated
vendored
27
vendor/github.com/BurntSushi/toml/COPYING
generated
vendored
@@ -1,14 +1,21 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
Copyright (c) 2013 TOML authors
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
27
vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING
generated
vendored
27
vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING
generated
vendored
@@ -1,14 +1,21 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
Copyright (c) 2013 TOML authors
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
27
vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING
generated
vendored
27
vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING
generated
vendored
@@ -1,14 +1,21 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
Copyright (c) 2013 TOML authors
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
27
vendor/github.com/BurntSushi/toml/cmd/tomlv/COPYING
generated
vendored
27
vendor/github.com/BurntSushi/toml/cmd/tomlv/COPYING
generated
vendored
@@ -1,14 +1,21 @@
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
Copyright (c) 2013 TOML authors
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
2
vendor/github.com/BurntSushi/toml/lex.go
generated
vendored
2
vendor/github.com/BurntSushi/toml/lex.go
generated
vendored
@@ -775,7 +775,7 @@ func lexDatetime(lx *lexer) stateFn {
|
||||
return lexDatetime
|
||||
}
|
||||
switch r {
|
||||
case '-', 'T', ':', '.', 'Z':
|
||||
case '-', 'T', ':', '.', 'Z', '+':
|
||||
return lexDatetime
|
||||
}
|
||||
|
||||
|
||||
1
vendor/github.com/ScaleFT/sshkeys/.gitignore
generated
vendored
Normal file
1
vendor/github.com/ScaleFT/sshkeys/.gitignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/vendor
|
||||
17
vendor/github.com/ScaleFT/sshkeys/.travis.yml
generated
vendored
Normal file
17
vendor/github.com/ScaleFT/sshkeys/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
language: go
|
||||
|
||||
sudo: false
|
||||
|
||||
go_import_path: github.com/ScaleFT/sshkeys
|
||||
|
||||
go:
|
||||
- 1.9.x
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
- tip
|
||||
|
||||
before_install:
|
||||
- go get -u github.com/stretchr/testify/require github.com/dchest/bcrypt_pbkdf golang.org/x/crypto/ed25519 golang.org/x/crypto/ssh
|
||||
|
||||
script:
|
||||
- go test -v ./...
|
||||
74
vendor/github.com/ScaleFT/sshkeys/CODE_OF_CONDUCT.md
generated
vendored
Normal file
74
vendor/github.com/ScaleFT/sshkeys/CODE_OF_CONDUCT.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at [opensource@scaleft.com](mailto:opensource@scaleft.com). All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
42
vendor/github.com/ScaleFT/sshkeys/CONTRIBUTING.md
generated
vendored
Normal file
42
vendor/github.com/ScaleFT/sshkeys/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
# How to Contribute
|
||||
|
||||
ScaleFT's projects are [Apache 2.0 licensed](LICENSE) and accept contributions
|
||||
via GitHub pull requests. This document outlines some of the conventions on
|
||||
development workflow, contact points, community conduct and other resources
|
||||
to make it easier to get your contribution accepted.
|
||||
|
||||
# Code of Conduct
|
||||
|
||||
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md).
|
||||
By participating, you are expected to uphold this code.
|
||||
|
||||
Please report unacceptable behavior to [opensource@scaleft.com](mailto:opensource@scaleft.com).
|
||||
|
||||
# Reporting Security Issues
|
||||
|
||||
ScaleFT takes security seriously. If you discover a security issue,
|
||||
please bring it to our attention right away!
|
||||
|
||||
Please DO NOT file a public issue or pull request,
|
||||
[instead send your report privately to the ScaleFT Security Team](https://www.scaleft.com/company/security/),
|
||||
reachable at [security@scaleft.com](mailto:security@scaleft.com).
|
||||
|
||||
Security reports are greatly appreciated and we will publicly thank you for them.
|
||||
|
||||
# Getting Started
|
||||
|
||||
- Fork the repository on GitHub
|
||||
- Read the [README](README.md) for build and test instructions
|
||||
- Play with the project, submit bugs, submit patches!
|
||||
|
||||
# Contribution Flow
|
||||
|
||||
This is a rough outline of what a contributor's workflow looks like:
|
||||
|
||||
- Create a topic branch from where you want to base your work (usually master).
|
||||
- Make commits of logical units, rebasing later is ok too!
|
||||
- Push your changes to a topic branch in your fork of the repository.
|
||||
- Make sure the tests pass, and add any new tests as appropriate.
|
||||
- Submit a pull request to the original repository.
|
||||
|
||||
Thanks for your contributions!
|
||||
202
vendor/github.com/ScaleFT/sshkeys/LICENSE
generated
vendored
Normal file
202
vendor/github.com/ScaleFT/sshkeys/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
10
vendor/github.com/ScaleFT/sshkeys/NOTICE
generated
vendored
Normal file
10
vendor/github.com/ScaleFT/sshkeys/NOTICE
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
sshkeys
|
||||
Copyright 2017 ScaleFT, Inc
|
||||
|
||||
This product includes software developed at ScaleFT, Inc.
|
||||
(https://www.scaleft.com/).
|
||||
|
||||
Portions of this software are derived from
|
||||
https://github.com/golang/crypto/blob/master/ssh/keys.go
|
||||
|
||||
Copyright (c) 2009 The Go Authors. All rights reserved.
|
||||
14
vendor/github.com/ScaleFT/sshkeys/README.md
generated
vendored
Normal file
14
vendor/github.com/ScaleFT/sshkeys/README.md
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# sshkeys
|
||||
|
||||
[](https://godoc.org/github.com/ScaleFT/sshkeys)
|
||||
[](https://travis-ci.org/ScaleFT/sshkeys)
|
||||
|
||||
`sshkeys` provides utilities for parsing and marshalling cryptographic keys used for SSH, in both cleartext and encrypted formats.
|
||||
|
||||
[ssh.ParseRawPrivateKey](https://godoc.org/golang.org/x/crypto/ssh#ParseRawPrivateKey) only supports parsing a subset of the formats `sshkeys` supports, does not support parsing encrypted private keys, and does not support marshalling.
|
||||
|
||||
## Supported Formats
|
||||
|
||||
* OpenSSH's [PROTOCOL.key](https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key) for RSA and ED25519 keys.
|
||||
* OpenSSH version >= 7.6 using aes256-ctr encryption
|
||||
* "Classic" PEM containing RSA (PKCS#1), DSA (OpenSSL), and ECDSA private keys.
|
||||
275
vendor/github.com/ScaleFT/sshkeys/marshal.go
generated
vendored
Normal file
275
vendor/github.com/ScaleFT/sshkeys/marshal.go
generated
vendored
Normal file
@@ -0,0 +1,275 @@
|
||||
package sshkeys
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/dsa"
|
||||
"crypto/ecdsa"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"encoding/asn1"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"math/big"
|
||||
mrand "math/rand"
|
||||
|
||||
"github.com/dchest/bcrypt_pbkdf"
|
||||
"golang.org/x/crypto/ed25519"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
// Format of private key to use when Marshaling.
|
||||
type Format int
|
||||
|
||||
const (
|
||||
// FormatOpenSSHv1 encodes a private key using OpenSSH's PROTOCOL.key format: https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
|
||||
FormatOpenSSHv1 Format = iota
|
||||
// FormatClassicPEM encodes private keys in PEM, with a key-specific encoding, as used by OpenSSH.
|
||||
FormatClassicPEM
|
||||
)
|
||||
|
||||
// MarshalOptions provides the Marshal function format and encryption options.
|
||||
type MarshalOptions struct {
|
||||
// Passphrase to encrypt private key with, if nil, the key will not be encrypted.
|
||||
Passphrase []byte
|
||||
// Format to encode the private key in.
|
||||
Format Format
|
||||
}
|
||||
|
||||
// Marshal converts a private key into an optionally encrypted format.
|
||||
func Marshal(pk interface{}, opts *MarshalOptions) ([]byte, error) {
|
||||
switch opts.Format {
|
||||
case FormatOpenSSHv1:
|
||||
return marshalOpenssh(pk, opts)
|
||||
case FormatClassicPEM:
|
||||
return marshalPem(pk, opts)
|
||||
default:
|
||||
return nil, fmt.Errorf("sshkeys: invalid format %d", opts.Format)
|
||||
}
|
||||
}
|
||||
|
||||
func marshalPem(pk interface{}, opts *MarshalOptions) ([]byte, error) {
|
||||
var err error
|
||||
var plain []byte
|
||||
var pemType string
|
||||
|
||||
switch key := pk.(type) {
|
||||
case *rsa.PrivateKey:
|
||||
pemType = "RSA PRIVATE KEY"
|
||||
plain = x509.MarshalPKCS1PrivateKey(key)
|
||||
case *ecdsa.PrivateKey:
|
||||
pemType = "EC PRIVATE KEY"
|
||||
plain, err = x509.MarshalECPrivateKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case *dsa.PrivateKey:
|
||||
pemType = "DSA PRIVATE KEY"
|
||||
plain, err = marshalDSAPrivateKey(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case *ed25519.PrivateKey:
|
||||
return nil, fmt.Errorf("sshkeys: ed25519 keys must be marshaled with FormatOpenSSHv1")
|
||||
default:
|
||||
return nil, fmt.Errorf("sshkeys: unsupported key type %T", pk)
|
||||
}
|
||||
|
||||
if len(opts.Passphrase) > 0 {
|
||||
block, err := x509.EncryptPEMBlock(rand.Reader, pemType, plain, opts.Passphrase, x509.PEMCipherAES128)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pem.EncodeToMemory(block), nil
|
||||
}
|
||||
|
||||
return pem.EncodeToMemory(&pem.Block{
|
||||
Type: pemType,
|
||||
Bytes: plain,
|
||||
}), nil
|
||||
}
|
||||
|
||||
type dsaOpenssl struct {
|
||||
Version int
|
||||
P *big.Int
|
||||
Q *big.Int
|
||||
G *big.Int
|
||||
Pub *big.Int
|
||||
Priv *big.Int
|
||||
}
|
||||
|
||||
// https://github.com/golang/crypto/blob/master/ssh/keys.go#L793-L804
|
||||
func marshalDSAPrivateKey(pk *dsa.PrivateKey) ([]byte, error) {
|
||||
k := dsaOpenssl{
|
||||
Version: 0,
|
||||
P: pk.P,
|
||||
Q: pk.Q,
|
||||
G: pk.G,
|
||||
Pub: pk.Y,
|
||||
Priv: pk.X,
|
||||
}
|
||||
|
||||
return asn1.Marshal(k)
|
||||
}
|
||||
|
||||
const opensshv1Magic = "openssh-key-v1"
|
||||
|
||||
type opensshHeader struct {
|
||||
CipherName string
|
||||
KdfName string
|
||||
KdfOpts string
|
||||
NumKeys uint32
|
||||
PubKey string
|
||||
PrivKeyBlock string
|
||||
}
|
||||
|
||||
type opensshKey struct {
|
||||
Check1 uint32
|
||||
Check2 uint32
|
||||
Keytype string
|
||||
Rest []byte `ssh:"rest"`
|
||||
}
|
||||
|
||||
type opensshRsa struct {
|
||||
N *big.Int
|
||||
E *big.Int
|
||||
D *big.Int
|
||||
Iqmp *big.Int
|
||||
P *big.Int
|
||||
Q *big.Int
|
||||
Comment string
|
||||
Pad []byte `ssh:"rest"`
|
||||
}
|
||||
|
||||
type opensshED25519 struct {
|
||||
Pub []byte
|
||||
Priv []byte
|
||||
Comment string
|
||||
Pad []byte `ssh:"rest"`
|
||||
}
|
||||
|
||||
func padBytes(data []byte, blocksize int) []byte {
|
||||
if blocksize != 0 {
|
||||
var i byte
|
||||
for i = byte(1); len(data)%blocksize != 0; i++ {
|
||||
data = append(data, i&0xFF)
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func marshalOpenssh(pk interface{}, opts *MarshalOptions) ([]byte, error) {
|
||||
var blocksize int
|
||||
var keylen int
|
||||
|
||||
out := opensshHeader{
|
||||
CipherName: "none",
|
||||
KdfName: "none",
|
||||
KdfOpts: "",
|
||||
NumKeys: 1,
|
||||
PubKey: "",
|
||||
}
|
||||
|
||||
if len(opts.Passphrase) > 0 {
|
||||
out.CipherName = "aes256-cbc"
|
||||
out.KdfName = "bcrypt"
|
||||
keylen = keySizeAES256
|
||||
blocksize = aes.BlockSize
|
||||
}
|
||||
|
||||
check := mrand.Uint32()
|
||||
pk1 := opensshKey{
|
||||
Check1: check,
|
||||
Check2: check,
|
||||
}
|
||||
|
||||
switch key := pk.(type) {
|
||||
case *rsa.PrivateKey:
|
||||
k := &opensshRsa{
|
||||
N: key.N,
|
||||
E: big.NewInt(int64(key.E)),
|
||||
D: key.D,
|
||||
Iqmp: key.Precomputed.Qinv,
|
||||
P: key.Primes[0],
|
||||
Q: key.Primes[1],
|
||||
Comment: "",
|
||||
}
|
||||
|
||||
data := ssh.Marshal(k)
|
||||
pk1.Keytype = ssh.KeyAlgoRSA
|
||||
pk1.Rest = data
|
||||
publicKey, err := ssh.NewPublicKey(&key.PublicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.PubKey = string(publicKey.Marshal())
|
||||
|
||||
case ed25519.PrivateKey:
|
||||
k := opensshED25519{
|
||||
Pub: key.Public().(ed25519.PublicKey),
|
||||
Priv: key,
|
||||
}
|
||||
data := ssh.Marshal(k)
|
||||
pk1.Keytype = ssh.KeyAlgoED25519
|
||||
pk1.Rest = data
|
||||
|
||||
publicKey, err := ssh.NewPublicKey(key.Public())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out.PubKey = string(publicKey.Marshal())
|
||||
default:
|
||||
return nil, fmt.Errorf("sshkeys: unsupported key type %T", pk)
|
||||
}
|
||||
|
||||
if len(opts.Passphrase) > 0 {
|
||||
rounds := 16
|
||||
ivlen := blocksize
|
||||
salt := make([]byte, blocksize)
|
||||
_, err := rand.Read(salt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
kdfdata, err := bcrypt_pbkdf.Key(opts.Passphrase, salt, rounds, keylen+ivlen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
iv := kdfdata[keylen : ivlen+keylen]
|
||||
aeskey := kdfdata[0:keylen]
|
||||
|
||||
block, err := aes.NewCipher(aeskey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pkblock := padBytes(ssh.Marshal(pk1), blocksize)
|
||||
|
||||
cbc := cipher.NewCBCEncrypter(block, iv)
|
||||
cbc.CryptBlocks(pkblock, pkblock)
|
||||
|
||||
out.PrivKeyBlock = string(pkblock)
|
||||
|
||||
var opts struct {
|
||||
Salt []byte
|
||||
Rounds uint32
|
||||
}
|
||||
|
||||
opts.Salt = salt
|
||||
opts.Rounds = uint32(rounds)
|
||||
|
||||
out.KdfOpts = string(ssh.Marshal(&opts))
|
||||
} else {
|
||||
out.PrivKeyBlock = string(ssh.Marshal(pk1))
|
||||
}
|
||||
|
||||
outBytes := []byte(opensshv1Magic)
|
||||
outBytes = append(outBytes, 0)
|
||||
outBytes = append(outBytes, ssh.Marshal(out)...)
|
||||
block := &pem.Block{
|
||||
Type: "OPENSSH PRIVATE KEY",
|
||||
Bytes: outBytes,
|
||||
}
|
||||
return pem.EncodeToMemory(block), nil
|
||||
}
|
||||
244
vendor/github.com/ScaleFT/sshkeys/parse.go
generated
vendored
Normal file
244
vendor/github.com/ScaleFT/sshkeys/parse.go
generated
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
// Portions of this file are based on https://github.com/golang/crypto/blob/master/ssh/keys.go
|
||||
//
|
||||
// Copyright 2012 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package sshkeys
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
"github.com/dchest/bcrypt_pbkdf"
|
||||
"golang.org/x/crypto/ed25519"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
// ErrIncorrectPassword is returned when the supplied passphrase was not correct for an encrypted private key.
|
||||
var ErrIncorrectPassword = errors.New("sshkeys: Invalid Passphrase")
|
||||
|
||||
const keySizeAES256 = 32
|
||||
|
||||
// ParseEncryptedPrivateKey returns a Signer from an encrypted private key. It supports
|
||||
// the same keys as ParseEncryptedRawPrivateKey.
|
||||
func ParseEncryptedPrivateKey(data []byte, passphrase []byte) (ssh.Signer, error) {
|
||||
key, err := ParseEncryptedRawPrivateKey(data, passphrase)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ssh.NewSignerFromKey(key)
|
||||
}
|
||||
|
||||
// ParseEncryptedRawPrivateKey returns a private key from an encrypted private key. It
|
||||
// supports RSA (PKCS#1 or OpenSSH), DSA (OpenSSL), and ECDSA private keys.
|
||||
//
|
||||
// ErrIncorrectPassword will be returned if the supplied passphrase is wrong,
|
||||
// but some formats like RSA in PKCS#1 detecting a wrong passphrase is difficult,
|
||||
// and other parse errors may be returned.
|
||||
func ParseEncryptedRawPrivateKey(data []byte, passphrase []byte) (interface{}, error) {
|
||||
var err error
|
||||
|
||||
block, _ := pem.Decode(data)
|
||||
if block == nil {
|
||||
return nil, errors.New("no PEM block found")
|
||||
}
|
||||
|
||||
if x509.IsEncryptedPEMBlock(block) {
|
||||
data, err = x509.DecryptPEMBlock(block, passphrase)
|
||||
if err == x509.IncorrectPasswordError {
|
||||
return nil, ErrIncorrectPassword
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
data = block.Bytes
|
||||
}
|
||||
|
||||
switch block.Type {
|
||||
case "RSA PRIVATE KEY":
|
||||
pk, err := x509.ParsePKCS1PrivateKey(data)
|
||||
if err != nil {
|
||||
// The Algos for PEM Encryption do not include strong message authentication,
|
||||
// so sometimes DecryptPEMBlock works, but ParsePKCS1PrivateKey fails with an asn1 error.
|
||||
// We are just catching the most common prefix here...
|
||||
if strings.HasPrefix(err.Error(), "asn1: structure error") {
|
||||
return nil, ErrIncorrectPassword
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return pk, nil
|
||||
case "EC PRIVATE KEY":
|
||||
return x509.ParseECPrivateKey(data)
|
||||
case "DSA PRIVATE KEY":
|
||||
return ssh.ParseDSAPrivateKey(data)
|
||||
case "OPENSSH PRIVATE KEY":
|
||||
return parseOpenSSHPrivateKey(data, passphrase)
|
||||
default:
|
||||
return nil, fmt.Errorf("sshkeys: unsupported key type %q", block.Type)
|
||||
}
|
||||
}
|
||||
|
||||
func parseOpenSSHPrivateKey(data []byte, passphrase []byte) (interface{}, error) {
|
||||
magic := append([]byte(opensshv1Magic), 0)
|
||||
if !bytes.Equal(magic, data[0:len(magic)]) {
|
||||
return nil, errors.New("sshkeys: invalid openssh private key format")
|
||||
}
|
||||
remaining := data[len(magic):]
|
||||
|
||||
w := opensshHeader{}
|
||||
|
||||
if err := ssh.Unmarshal(remaining, &w); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if w.NumKeys != 1 {
|
||||
return nil, fmt.Errorf("sshkeys: NumKeys must be 1: %d", w.NumKeys)
|
||||
}
|
||||
|
||||
var privateKeyBytes []byte
|
||||
var encrypted bool
|
||||
|
||||
switch {
|
||||
// OpenSSH supports bcrypt KDF w/ AES256-CBC or AES256-CTR mode
|
||||
case w.KdfName == "bcrypt" && w.CipherName == "aes256-cbc":
|
||||
iv, block, err := extractBcryptIvBlock(passphrase, w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cbc := cipher.NewCBCDecrypter(block, iv)
|
||||
privateKeyBytes = []byte(w.PrivKeyBlock)
|
||||
cbc.CryptBlocks(privateKeyBytes, privateKeyBytes)
|
||||
|
||||
encrypted = true
|
||||
|
||||
case w.KdfName == "bcrypt" && w.CipherName == "aes256-ctr":
|
||||
iv, block, err := extractBcryptIvBlock(passphrase, w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
stream := cipher.NewCTR(block, iv)
|
||||
privateKeyBytes = []byte(w.PrivKeyBlock)
|
||||
stream.XORKeyStream(privateKeyBytes, privateKeyBytes)
|
||||
|
||||
encrypted = true
|
||||
|
||||
case w.KdfName == "none" && w.CipherName == "none":
|
||||
privateKeyBytes = []byte(w.PrivKeyBlock)
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("sshkeys: unknown Cipher/KDF: %s:%s", w.CipherName, w.KdfName)
|
||||
}
|
||||
|
||||
pk1 := opensshKey{}
|
||||
|
||||
if err := ssh.Unmarshal(privateKeyBytes, &pk1); err != nil {
|
||||
if encrypted {
|
||||
return nil, ErrIncorrectPassword
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if pk1.Check1 != pk1.Check2 {
|
||||
return nil, ErrIncorrectPassword
|
||||
}
|
||||
|
||||
// we only handle ed25519 and rsa keys currently
|
||||
switch pk1.Keytype {
|
||||
case ssh.KeyAlgoRSA:
|
||||
// https://github.com/openssh/openssh-portable/blob/V_7_4_P1/sshkey.c#L2760-L2773
|
||||
key := opensshRsa{}
|
||||
|
||||
err := ssh.Unmarshal(pk1.Rest, &key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i, b := range key.Pad {
|
||||
if int(b) != i+1 {
|
||||
return nil, errors.New("sshkeys: padding not as expected")
|
||||
}
|
||||
}
|
||||
|
||||
pk := &rsa.PrivateKey{
|
||||
PublicKey: rsa.PublicKey{
|
||||
N: key.N,
|
||||
E: int(key.E.Int64()),
|
||||
},
|
||||
D: key.D,
|
||||
Primes: []*big.Int{key.P, key.Q},
|
||||
}
|
||||
|
||||
err = pk.Validate()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pk.Precompute()
|
||||
|
||||
return pk, nil
|
||||
case ssh.KeyAlgoED25519:
|
||||
key := opensshED25519{}
|
||||
|
||||
err := ssh.Unmarshal(pk1.Rest, &key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(key.Priv) != ed25519.PrivateKeySize {
|
||||
return nil, errors.New("sshkeys: private key unexpected length")
|
||||
}
|
||||
|
||||
for i, b := range key.Pad {
|
||||
if int(b) != i+1 {
|
||||
return nil, errors.New("sshkeys: padding not as expected")
|
||||
}
|
||||
}
|
||||
|
||||
pk := ed25519.PrivateKey(make([]byte, ed25519.PrivateKeySize))
|
||||
copy(pk, key.Priv)
|
||||
return pk, nil
|
||||
default:
|
||||
return nil, errors.New("sshkeys: unhandled key type")
|
||||
}
|
||||
}
|
||||
|
||||
func extractBcryptIvBlock(passphrase []byte, w opensshHeader) ([]byte, cipher.Block, error) {
|
||||
cipherKeylen := keySizeAES256
|
||||
cipherIvLen := aes.BlockSize
|
||||
|
||||
var opts struct {
|
||||
Salt []byte
|
||||
Rounds uint32
|
||||
}
|
||||
|
||||
if err := ssh.Unmarshal([]byte(w.KdfOpts), &opts); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
kdfdata, err := bcrypt_pbkdf.Key(passphrase, opts.Salt, int(opts.Rounds), cipherKeylen+cipherIvLen)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
iv := kdfdata[cipherKeylen : cipherIvLen+cipherKeylen]
|
||||
aeskey := kdfdata[0:cipherKeylen]
|
||||
block, err := aes.NewCipher(aeskey)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return iv, block, nil
|
||||
}
|
||||
27
vendor/github.com/dchest/bcrypt_pbkdf/LICENSE
generated
vendored
Normal file
27
vendor/github.com/dchest/bcrypt_pbkdf/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
Copyright (c) 2014 Dmitry Chestnykh <dmitry@codingrobots.com>
|
||||
Copyright (c) 2010 The Go Authors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
21
vendor/github.com/dchest/bcrypt_pbkdf/README
generated
vendored
Normal file
21
vendor/github.com/dchest/bcrypt_pbkdf/README
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Go implementation of bcrypt_pbkdf(3) from OpenBSD
|
||||
(a variant of PBKDF2 with bcrypt-based PRF).
|
||||
|
||||
|
||||
USAGE
|
||||
|
||||
func Key(password, salt []byte, rounds, keyLen int) ([]byte, error)
|
||||
|
||||
|
||||
Key derives a key from the password, salt and rounds count, returning a
|
||||
[]byte of length keyLen that can be used as cryptographic key.
|
||||
|
||||
Remember to get a good random salt of at least 16 bytes. Using a higher
|
||||
rounds count will increase the cost of an exhaustive search but will also
|
||||
make derivation proportionally slower.
|
||||
|
||||
|
||||
REFERENCES
|
||||
|
||||
* http://www.tedunangst.com/flak/post/bcrypt-pbkdf
|
||||
* http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libutil/bcrypt_pbkdf.c
|
||||
97
vendor/github.com/dchest/bcrypt_pbkdf/bcrypt_pbkdf.go
generated
vendored
Normal file
97
vendor/github.com/dchest/bcrypt_pbkdf/bcrypt_pbkdf.go
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
// Copyright 2014 Dmitry Chestnykh. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package bcrypt_pbkdf implements password-based key derivation function based
|
||||
// on bcrypt compatible with bcrypt_pbkdf(3) from OpenBSD.
|
||||
package bcrypt_pbkdf
|
||||
|
||||
import (
|
||||
"crypto/sha512"
|
||||
"errors"
|
||||
|
||||
// NOTE! Requires blowfish package version from Aug 1, 2014 or later.
|
||||
// Will produce incorrect results if the package is older.
|
||||
// See commit message for details: http://goo.gl/wx6g8O
|
||||
"golang.org/x/crypto/blowfish"
|
||||
)
|
||||
|
||||
// Key derives a key from the password, salt and rounds count, returning a
|
||||
// []byte of length keyLen that can be used as cryptographic key.
|
||||
//
|
||||
// Remember to get a good random salt of at least 16 bytes. Using a higher
|
||||
// rounds count will increase the cost of an exhaustive search but will also
|
||||
// make derivation proportionally slower.
|
||||
func Key(password, salt []byte, rounds, keyLen int) ([]byte, error) {
|
||||
if rounds < 1 {
|
||||
return nil, errors.New("bcrypt_pbkdf: number of rounds is too small")
|
||||
}
|
||||
if len(password) == 0 {
|
||||
return nil, errors.New("bcrypt_pbkdf: empty password")
|
||||
}
|
||||
if len(salt) == 0 || len(salt) > 1<<20 {
|
||||
return nil, errors.New("bcrypt_pbkdf: bad salt length")
|
||||
}
|
||||
if keyLen > 1024 {
|
||||
return nil, errors.New("bcrypt_pbkdf: keyLen is too large")
|
||||
}
|
||||
var shapass, shasalt [sha512.Size]byte
|
||||
var out, tmp [32]byte
|
||||
var cnt [4]byte
|
||||
|
||||
numBlocks := (keyLen + len(out) - 1) / len(out)
|
||||
key := make([]byte, numBlocks*len(out))
|
||||
|
||||
h := sha512.New()
|
||||
h.Write(password)
|
||||
h.Sum(shapass[:0])
|
||||
|
||||
for block := 1; block <= numBlocks; block++ {
|
||||
h.Reset()
|
||||
h.Write(salt)
|
||||
cnt[0] = byte(block >> 24)
|
||||
cnt[1] = byte(block >> 16)
|
||||
cnt[2] = byte(block >> 8)
|
||||
cnt[3] = byte(block)
|
||||
h.Write(cnt[:])
|
||||
bcryptHash(tmp[:], shapass[:], h.Sum(shasalt[:0]))
|
||||
copy(out[:], tmp[:])
|
||||
|
||||
for i := 2; i <= rounds; i++ {
|
||||
h.Reset()
|
||||
h.Write(tmp[:])
|
||||
bcryptHash(tmp[:], shapass[:], h.Sum(shasalt[:0]))
|
||||
for j := 0; j < len(out); j++ {
|
||||
out[j] ^= tmp[j]
|
||||
}
|
||||
}
|
||||
|
||||
for i, v := range out {
|
||||
key[i*numBlocks+(block-1)] = v
|
||||
}
|
||||
}
|
||||
return key[:keyLen], nil
|
||||
}
|
||||
|
||||
var magic = []byte("OxychromaticBlowfishSwatDynamite")
|
||||
|
||||
func bcryptHash(out, shapass, shasalt []byte) {
|
||||
c, err := blowfish.NewSaltedCipher(shapass, shasalt)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for i := 0; i < 64; i++ {
|
||||
blowfish.ExpandKey(shasalt, c)
|
||||
blowfish.ExpandKey(shapass, c)
|
||||
}
|
||||
copy(out[:], magic)
|
||||
for i := 0; i < 32; i += 8 {
|
||||
for j := 0; j < 64; j++ {
|
||||
c.Encrypt(out[i:i+8], out[i:i+8])
|
||||
}
|
||||
}
|
||||
// Swap bytes due to different endianness.
|
||||
for i := 0; i < 32; i += 4 {
|
||||
out[i+3], out[i+2], out[i+1], out[i] = out[i], out[i+1], out[i+2], out[i+3]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user