mirror of
https://github.com/refraction-networking/utls.git
synced 2025-04-03 20:17:36 +03:00
new ClientHellos and Extensions (#116)
* Implement certificate compression
Certificate compression is defined in RFC 8879:
https://datatracker.ietf.org/doc/html/rfc8879
This implementation is client-side only, for server certificates.
* Fix missing LOC
* Add more fingerprints
* Implement ALPS extension
* Merge commit fcaacdbbe7
- At this commit, github.com/Noooste/utls remained at the original upstream LICENSE
* added HelloChrome102 and HelloFirefox102
* Randomly include ALPS in HelloRandomized
Co-authored-by: Harry Harpham <harry@getlantern.org>
Co-authored-by: Sleeyax <yourd3veloper@gmail.com>
Co-authored-by: Rod Hynes <rod-hynes@users.noreply.github.com>
This commit is contained in:
parent
4d3785b233
commit
f781b699a2
5 changed files with 884 additions and 14 deletions
26
u_prng.go
26
u_prng.go
|
@ -19,6 +19,7 @@ import (
|
|||
"math/rand"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/crypto/hkdf"
|
||||
"golang.org/x/crypto/sha3"
|
||||
)
|
||||
|
||||
|
@ -39,6 +40,21 @@ func NewPRNGSeed() (*PRNGSeed, error) {
|
|||
return seed, nil
|
||||
}
|
||||
|
||||
// newSaltedPRNGSeed creates a new seed derived from an existing seed and a
|
||||
// salt. A HKDF is applied to the seed and salt.
|
||||
//
|
||||
// newSaltedPRNGSeed is intended for use cases where a single seed needs to be
|
||||
// used in distinct contexts to produce independent random streams.
|
||||
func newSaltedPRNGSeed(seed *PRNGSeed, salt string) (*PRNGSeed, error) {
|
||||
saltedSeed := new(PRNGSeed)
|
||||
_, err := io.ReadFull(
|
||||
hkdf.New(sha3.New256, seed[:], []byte(salt), nil), saltedSeed[:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return saltedSeed, nil
|
||||
}
|
||||
|
||||
// prng is a seeded, unbiased PRNG based on SHAKE256. that is suitable for use
|
||||
// cases such as obfuscation. Seeding is based on crypto/rand.Read.
|
||||
//
|
||||
|
@ -78,6 +94,16 @@ func newPRNGWithSeed(seed *PRNGSeed) (*prng, error) {
|
|||
return p, nil
|
||||
}
|
||||
|
||||
// newPRNGWithSaltedSeed initializes a new PRNG using a seed derived from an
|
||||
// existing seed and a salt with NewSaltedSeed.
|
||||
func newPRNGWithSaltedSeed(seed *PRNGSeed, salt string) (*prng, error) {
|
||||
saltedSeed, err := newSaltedPRNGSeed(seed, salt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newPRNGWithSeed(saltedSeed)
|
||||
}
|
||||
|
||||
// Read reads random bytes from the PRNG stream into b. Read conforms to
|
||||
// io.Reader and always returns len(p), nil.
|
||||
func (p *prng) Read(b []byte) (int, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue