mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-23 08:02:57 -06:00
Grand test fixup (#138)
* start fixing up tests * fix up tests + automate with drone * fiddle with linting * messing about with drone.yml * some more fiddling * hmmm * add cache * add vendor directory * verbose * ci updates * update some little things * update sig
This commit is contained in:
parent
329a5e8144
commit
98263a7de6
2677 changed files with 1090869 additions and 219 deletions
30
vendor/mellium.im/sasl/nonce.go
vendored
Normal file
30
vendor/mellium.im/sasl/nonce.go
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2016 The Mellium Contributors.
|
||||
// Use of this source code is governed by the BSD 2-clause license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package sasl
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"io"
|
||||
)
|
||||
|
||||
// Generates a nonce with n random bytes base64 encoded to ensure that it meets
|
||||
// the criteria for inclusion in a SCRAM message.
|
||||
func nonce(n int, r io.Reader) []byte {
|
||||
if n < 1 {
|
||||
panic("Cannot generate zero or negative length nonce")
|
||||
}
|
||||
b := make([]byte, n)
|
||||
n2, err := r.Read(b)
|
||||
switch {
|
||||
case err != nil:
|
||||
panic(err)
|
||||
case n2 != n:
|
||||
panic("Could not read enough randomness to generate nonce")
|
||||
}
|
||||
val := make([]byte, base64.RawStdEncoding.EncodedLen(n))
|
||||
base64.RawStdEncoding.Encode(val, b)
|
||||
|
||||
return val
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue