mirror of
https://gogs.blitter.com/RLabs/xs
synced 2024-08-14 10:26:42 +00:00
Merge tag 'v0.8.19' into xc-bigfile-EOF
This commit is contained in:
commit
3b0ddba7f2
28 changed files with 2975 additions and 266 deletions
|
@ -21,7 +21,7 @@ import (
|
|||
"log"
|
||||
|
||||
"blitter.com/go/cryptmt"
|
||||
"blitter.com/go/wanderer"
|
||||
"github.com/aead/chacha20/chacha"
|
||||
"golang.org/x/crypto/blowfish"
|
||||
"golang.org/x/crypto/twofish"
|
||||
|
||||
|
@ -103,11 +103,20 @@ func (hc Conn) getStream(keymat []byte) (rc cipher.Stream, mc hash.Hash, err err
|
|||
rc = cipher.NewOFB(block, iv)
|
||||
log.Printf("[cipher BLOWFISH_64 (%d)]\n", copts)
|
||||
case CAlgCryptMT1:
|
||||
rc = cryptmt.NewCipher(keymat)
|
||||
rc = cryptmt.New(nil, nil, keymat)
|
||||
log.Printf("[cipher CRYPTMT1 (%d)]\n", copts)
|
||||
case CAlgWanderer:
|
||||
rc = wanderer.NewCodec(nil, nil, 1, keymat, 3, 3)
|
||||
log.Printf("[cipher WANDERER mode 1 (%d)]\n", copts)
|
||||
case CAlgChaCha20_12:
|
||||
keymat = expandKeyMat(keymat, chacha.KeySize)
|
||||
key = keymat[0:chacha.KeySize]
|
||||
ivlen = chacha.INonceSize
|
||||
iv = keymat[chacha.KeySize : chacha.KeySize+ivlen]
|
||||
rc, err = chacha.NewCipher(iv, key, 20)
|
||||
if err != nil {
|
||||
log.Printf("[ChaCha20 config error]\n")
|
||||
fmt.Printf("[ChaCha20 config error]\n")
|
||||
}
|
||||
// TODO: SetCounter() to something derived from key or nonce or extra keymat?
|
||||
log.Printf("[cipher CHACHA20_12 (%d)]\n", copts)
|
||||
default:
|
||||
log.Printf("[invalid cipher (%d)]\n", copts)
|
||||
fmt.Printf("DOOFUS SET A VALID CIPHER ALG (%d)\n", copts)
|
||||
|
|
|
@ -99,7 +99,7 @@ const (
|
|||
CAlgTwofish128 // golang.org/x/crypto/twofish
|
||||
CAlgBlowfish64 // golang.org/x/crypto/blowfish
|
||||
CAlgCryptMT1 //cryptmt using mtwist64
|
||||
CAlgWanderer // inhouse experimental crypto alg
|
||||
CAlgChaCha20_12
|
||||
CAlgNoneDisallowed
|
||||
)
|
||||
|
||||
|
|
16
xsnet/net.go
16
xsnet/net.go
|
@ -41,9 +41,9 @@ import (
|
|||
"time"
|
||||
|
||||
hkex "blitter.com/go/herradurakex"
|
||||
"blitter.com/go/xs/logger"
|
||||
"blitter.com/go/kyber"
|
||||
"blitter.com/go/newhope"
|
||||
"blitter.com/go/xs/logger"
|
||||
)
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
|
@ -145,8 +145,8 @@ func (c *CSCipherAlg) String() string {
|
|||
return "C_BLOWFISH_64"
|
||||
case CAlgCryptMT1:
|
||||
return "C_CRYPTMT1"
|
||||
case CAlgWanderer:
|
||||
return "C_WANDERER"
|
||||
case CAlgChaCha20_12:
|
||||
return "C_CHACHA20_12"
|
||||
default:
|
||||
return "C_ERR_UNK"
|
||||
}
|
||||
|
@ -282,6 +282,8 @@ func _new(kexAlg KEXAlg, conn *net.Conn) (hc *Conn, e error) {
|
|||
hc.kex = KEX_HERRADURA512
|
||||
log.Printf("[KEx alg %d ?? defaults to %d]\n", kexAlg, hc.kex)
|
||||
}
|
||||
|
||||
//hc.logCipherText = true // !!! DEBUGGING ONLY !!! NEVER DEPLOY this uncommented !!!
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -300,7 +302,7 @@ func _new(kexAlg KEXAlg, conn *net.Conn) (hc *Conn, e error) {
|
|||
//
|
||||
// Session (symmetric) crypto
|
||||
//
|
||||
// C_AES_256 C_TWOFISH_128 C_BLOWFISH_128 C_CRYPTMT1
|
||||
// C_AES_256 C_TWOFISH_128 C_BLOWFISH_128 C_CRYPTMT1 C_CHACHA20_12
|
||||
//
|
||||
// Session HMACs
|
||||
//
|
||||
|
@ -324,10 +326,10 @@ func (hc *Conn) applyConnExtensions(extensions ...string) {
|
|||
log.Println("[extension arg = C_CRYPTMT1]")
|
||||
hc.cipheropts &= (0xFFFFFF00)
|
||||
hc.cipheropts |= CAlgCryptMT1
|
||||
case "C_WANDERER":
|
||||
log.Println("[extension arg = C_WANDERER]")
|
||||
case "C_CHACHA20_12":
|
||||
log.Println("[extension arg = C_CHACHA20_12]")
|
||||
hc.cipheropts &= (0xFFFFFF00)
|
||||
hc.cipheropts |= CAlgWanderer
|
||||
hc.cipheropts |= CAlgChaCha20_12
|
||||
case "H_SHA256":
|
||||
log.Println("[extension arg = H_SHA256]")
|
||||
hc.cipheropts &= (0xFFFF00FF)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue