Skip to content

Commit 3d7db7d

Browse files
drakkangopherbot
authored andcommitted
design/68723-crypto-ssh-v2.md: change NewPublicKey signature
It now accepts a crypto.PublicKey instead of an empty interface. All public keys in the standard library implement this interface. Change-Id: I873175a4d4e57803dc3cafdadb800b4f34ae0ca1 GitHub-Last-Rev: 05a3b07 GitHub-Pull-Request: #54 Reviewed-on: https://go-review.googlesource.com/c/proposal/+/614279 Reviewed-by: Nicola Murino <[email protected]> Commit-Queue: Nicola Murino <[email protected]> Auto-Submit: Nicola Murino <[email protected]>
1 parent 1663299 commit 3d7db7d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

design/68723-crypto-ssh-v2.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ func MarshalPrivateKey(key crypto.PrivateKey, options MarshalPrivateKeyOptions)
425425

426426
This way we can remove `MarshalPrivateKeyWithPassphrase` because the passphrase is now an option. We can easily add support for other options, for example making salt rounds confgurable, see [golang/go#68700](https://github.com/golang/go/issues/68700).
427427

428+
### NewPublicKey
429+
430+
Change the `NewPublicKey` signature to accept `crypto.PublicKey` instead of an empty interface. All public keys in the standard library implement this interface.
431+
428432
### Deprecated API and algorithms removal
429433

430434
We'll remove DSA support, see [here](https://lists.mindrot.org/pipermail/openssh-unix-announce/2024-January/000156.html) for DSA status in OpenSSH, it is already disabled by default and will be removed in January, 2025.

design/68723/ssh.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ <h3 id="pkg-index">Index</h3>
777777
<li>
778778
<a href="#PublicKey">type PublicKey</a>
779779
<ul>
780-
<li><a href="#NewPublicKey">func NewPublicKey(key interface{}) (PublicKey, error)</a></li>
780+
<li><a href="#NewPublicKey">func NewPublicKey(key crypto.PublicKey) (PublicKey, error)</a></li>
781781
<li><a href="#ParseAuthorizedKey">func ParseAuthorizedKey(in []byte) (out PublicKey, comment string, options []string, rest []byte, err error)</a></li>
782782
<li><a href="#ParseKnownHosts">func ParseKnownHosts(in []byte) (marker string, hosts []string, pubKey PublicKey, comment string, rest []byte, ...)</a></li>
783783
<li><a href="#ParsePublicKey">func ParsePublicKey(in []byte) (out PublicKey, err error)</a></li>
@@ -1986,10 +1986,10 @@ <h3 id="PublicKey">type PublicKey</h3>
19861986
<p>PublicKey represents a public key using an unspecified algorithm.
19871987
<p>Some PublicKeys provided by this package also implement CryptoPublicKey.
19881988
<h4 id="NewPublicKey">func NewPublicKey</h4>
1989-
<pre class="chroma"><span class="kd">func</span> <span class="nf">NewPublicKey</span><span class="p">(</span><span class="nx">key</span> <span class="kd">interface</span><span class="p">{})</span> <span class="p">(</span><a href="#PublicKey"><span class="nx">PublicKey</span></a><span class="p">,</span> <a href="https://pkg.go.dev/builtin#error"><span class="kt">error</span></a><span class="p">)</span></pre>
1990-
<p>NewPublicKey takes an *rsa.PublicKey, *dsa.PublicKey, *ecdsa.PublicKey,
1991-
or ed25519.PublicKey returns a corresponding PublicKey instance.
1992-
ECDSA keys must use P-256, P-384 or P-521.
1989+
<pre class="chroma"><span class="kd">func</span> <span class="nf">NewPublicKey</span><span class="p">(</span><span class="nx">key</span> <a href="https://pkg.go.dev/crypto"><span class="nx">crypto</span></a><span class="p">.</span><a href="https://pkg.go.dev/crypto#PublicKey"><span class="nx">PublicKey</span></a><span class="p">)</span> <span class="p">(</span><a href="#PublicKey"><span class="nx">PublicKey</span></a><span class="p">,</span> <a href="https://pkg.go.dev/builtin#error"><span class="kt">error</span></a><span class="p">)</span></pre>
1990+
<p>NewPublicKey takes an *rsa.PublicKey, *ecdsa.PublicKey, or ed25519.PublicKey
1991+
returns a corresponding PublicKey instance. ECDSA keys must use P-256, P-384
1992+
or P-521.
19931993
<h4 id="ParseAuthorizedKey">func ParseAuthorizedKey</h4>
19941994
<pre class="chroma"><span class="kd">func</span> <span class="nf">ParseAuthorizedKey</span><span class="p">(</span><span class="nx">in</span> <span class="p">[]</span><a href="https://pkg.go.dev/builtin#byte"><span class="kt">byte</span></a><span class="p">)</span> <span class="p">(</span><span class="nx">out</span> <a href="#PublicKey"><span class="nx">PublicKey</span></a><span class="p">,</span> <span class="nx">comment</span> <a href="https://pkg.go.dev/builtin#string"><span class="kt">string</span></a><span class="p">,</span> <span class="nx">options</span> <span class="p">[]</span><a href="https://pkg.go.dev/builtin#string"><span class="kt">string</span></a><span class="p">,</span> <span class="nx">rest</span> <span class="p">[]</span><a href="https://pkg.go.dev/builtin#byte"><span class="kt">byte</span></a><span class="p">,</span> <span class="nx">err</span> <a href="https://pkg.go.dev/builtin#error"><span class="kt">error</span></a><span class="p">)</span></pre>
19951995
<p>ParseAuthorizedKey parses a public key from an authorized_keys

0 commit comments

Comments
 (0)