mirror of
https://github.com/miekg/dns.git
synced 2025-10-13 02:41:01 +02:00
* Add support for Ed25519 DNSSEC signing from RFC 8080 Note: The test case from RFC 8080 has been modified to correct the missing final brace, but is otherwise present as-is. * Explain why ed25519 is special cased in (*RRSIG).Sign * Explain use of ed25519.GenerateKey in readPrivateKeyED25519 * Add dep This is PR #458 with the dependency added into it.
36 lines
817 B
Go
36 lines
817 B
Go
// Copyright 2011 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 bcrypt
|
|
|
|
import "encoding/base64"
|
|
|
|
const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
|
|
var bcEncoding = base64.NewEncoding(alphabet)
|
|
|
|
func base64Encode(src []byte) []byte {
|
|
n := bcEncoding.EncodedLen(len(src))
|
|
dst := make([]byte, n)
|
|
bcEncoding.Encode(dst, src)
|
|
for dst[n-1] == '=' {
|
|
n--
|
|
}
|
|
return dst[:n]
|
|
}
|
|
|
|
func base64Decode(src []byte) ([]byte, error) {
|
|
numOfEquals := 4 - (len(src) % 4)
|
|
for i := 0; i < numOfEquals; i++ {
|
|
src = append(src, '=')
|
|
}
|
|
|
|
dst := make([]byte, bcEncoding.DecodedLen(len(src)))
|
|
n, err := bcEncoding.Decode(dst, src)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return dst[:n], nil
|
|
}
|