mirror of
				https://gogs.blitter.com/RLabs/xs
				synced 2024-08-14 10:26:42 +00:00 
			
		
		
		
	WIP integrating experimental WANDERER alg
This commit is contained in:
		
							parent
							
								
									d542e4949e
								
							
						
					
					
						commit
						e58572ebb5
					
				
					 4 changed files with 16 additions and 12 deletions
				
			
		|  | @ -95,6 +95,7 @@ const ( | ||||||
| 	CAlgTwofish128 // golang.org/x/crypto/twofish | 	CAlgTwofish128 // golang.org/x/crypto/twofish | ||||||
| 	CAlgBlowfish64 // golang.org/x/crypto/blowfish | 	CAlgBlowfish64 // golang.org/x/crypto/blowfish | ||||||
| 	CAlgCryptMT1   //cryptmt using mtwist64 | 	CAlgCryptMT1   //cryptmt using mtwist64 | ||||||
|  | 	CAlgWanderer   // inhouse experimental crypto alg | ||||||
| 	CAlgNoneDisallowed | 	CAlgNoneDisallowed | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -20,9 +20,11 @@ import ( | ||||||
| 	"hash" | 	"hash" | ||||||
| 	"log" | 	"log" | ||||||
| 
 | 
 | ||||||
|  | 	"blitter.com/go/cryptmt" | ||||||
|  | 	"blitter.com/go/wanderer" | ||||||
| 	"golang.org/x/crypto/blowfish" | 	"golang.org/x/crypto/blowfish" | ||||||
| 	"golang.org/x/crypto/twofish" | 	"golang.org/x/crypto/twofish" | ||||||
| 	"blitter.com/go/cryptmt" | 
 | ||||||
| 	// hash algos must be manually imported thusly: | 	// hash algos must be manually imported thusly: | ||||||
| 	// (Would be nice if the golang pkg docs were more clear | 	// (Would be nice if the golang pkg docs were more clear | ||||||
| 	// on this...) | 	// on this...) | ||||||
|  | @ -75,7 +77,6 @@ func (hc Conn) getStream(keymat []byte) (rc cipher.Stream, mc hash.Hash, err err | ||||||
| 		iv = keymat[aes.BlockSize : aes.BlockSize+ivlen] | 		iv = keymat[aes.BlockSize : aes.BlockSize+ivlen] | ||||||
| 		rc = cipher.NewOFB(block, iv) | 		rc = cipher.NewOFB(block, iv) | ||||||
| 		log.Printf("[cipher AES_256 (%d)]\n", copts) | 		log.Printf("[cipher AES_256 (%d)]\n", copts) | ||||||
| 		break |  | ||||||
| 	case CAlgTwofish128: | 	case CAlgTwofish128: | ||||||
| 		keymat = expandKeyMat(keymat, twofish.BlockSize) | 		keymat = expandKeyMat(keymat, twofish.BlockSize) | ||||||
| 		key = keymat[0:twofish.BlockSize] | 		key = keymat[0:twofish.BlockSize] | ||||||
|  | @ -84,7 +85,6 @@ func (hc Conn) getStream(keymat []byte) (rc cipher.Stream, mc hash.Hash, err err | ||||||
| 		iv = keymat[twofish.BlockSize : twofish.BlockSize+ivlen] | 		iv = keymat[twofish.BlockSize : twofish.BlockSize+ivlen] | ||||||
| 		rc = cipher.NewOFB(block, iv) | 		rc = cipher.NewOFB(block, iv) | ||||||
| 		log.Printf("[cipher TWOFISH_128 (%d)]\n", copts) | 		log.Printf("[cipher TWOFISH_128 (%d)]\n", copts) | ||||||
| 		break |  | ||||||
| 	case CAlgBlowfish64: | 	case CAlgBlowfish64: | ||||||
| 		keymat = expandKeyMat(keymat, blowfish.BlockSize) | 		keymat = expandKeyMat(keymat, blowfish.BlockSize) | ||||||
| 		key = keymat[0:blowfish.BlockSize] | 		key = keymat[0:blowfish.BlockSize] | ||||||
|  | @ -102,11 +102,12 @@ func (hc Conn) getStream(keymat []byte) (rc cipher.Stream, mc hash.Hash, err err | ||||||
| 		iv = keymat[blowfish.BlockSize : blowfish.BlockSize+ivlen] | 		iv = keymat[blowfish.BlockSize : blowfish.BlockSize+ivlen] | ||||||
| 		rc = cipher.NewOFB(block, iv) | 		rc = cipher.NewOFB(block, iv) | ||||||
| 		log.Printf("[cipher BLOWFISH_64 (%d)]\n", copts) | 		log.Printf("[cipher BLOWFISH_64 (%d)]\n", copts) | ||||||
| 		break |  | ||||||
| 	case CAlgCryptMT1: | 	case CAlgCryptMT1: | ||||||
| 		rc = cryptmt.NewCipher(keymat) | 		rc = cryptmt.NewCipher(keymat) | ||||||
| 		log.Printf("[cipher CRYPTMT1 (%d)]\n", copts) | 		log.Printf("[cipher CRYPTMT1 (%d)]\n", copts) | ||||||
| 		break | 	case CAlgWanderer: | ||||||
|  | 		rc = wanderer.NewCodec(nil, nil, keymat, 3, 3) | ||||||
|  | 		log.Printf("[cipher WANDERER (%d)]\n", copts) | ||||||
| 	default: | 	default: | ||||||
| 		log.Printf("[invalid cipher (%d)]\n", copts) | 		log.Printf("[invalid cipher (%d)]\n", copts) | ||||||
| 		fmt.Printf("DOOFUS SET A VALID CIPHER ALG (%d)\n", copts) | 		fmt.Printf("DOOFUS SET A VALID CIPHER ALG (%d)\n", copts) | ||||||
|  | @ -123,7 +124,6 @@ func (hc Conn) getStream(keymat []byte) (rc cipher.Stream, mc hash.Hash, err err | ||||||
| 		if !halg.Available() { | 		if !halg.Available() { | ||||||
| 			log.Fatal("hash not available!") | 			log.Fatal("hash not available!") | ||||||
| 		} | 		} | ||||||
| 		break |  | ||||||
| 	case HmacSHA512: | 	case HmacSHA512: | ||||||
| 		log.Printf("[hash HmacSHA512 (%d)]\n", hopts) | 		log.Printf("[hash HmacSHA512 (%d)]\n", hopts) | ||||||
| 		halg := crypto.SHA512 | 		halg := crypto.SHA512 | ||||||
|  | @ -131,7 +131,6 @@ func (hc Conn) getStream(keymat []byte) (rc cipher.Stream, mc hash.Hash, err err | ||||||
| 		if !halg.Available() { | 		if !halg.Available() { | ||||||
| 			log.Fatal("hash not available!") | 			log.Fatal("hash not available!") | ||||||
| 		} | 		} | ||||||
| 		break |  | ||||||
| 	default: | 	default: | ||||||
| 		log.Printf("[invalid hmac (%d)]\n", hopts) | 		log.Printf("[invalid hmac (%d)]\n", hopts) | ||||||
| 		fmt.Printf("DOOFUS SET A VALID HMAC ALG (%d)\n", hopts) | 		fmt.Printf("DOOFUS SET A VALID HMAC ALG (%d)\n", hopts) | ||||||
|  |  | ||||||
|  | @ -258,6 +258,10 @@ func (hc *Conn) applyConnExtensions(extensions ...string) { | ||||||
| 			log.Println("[extension arg = C_CRYPTMT1]") | 			log.Println("[extension arg = C_CRYPTMT1]") | ||||||
| 			hc.cipheropts &= (0xFFFFFF00) | 			hc.cipheropts &= (0xFFFFFF00) | ||||||
| 			hc.cipheropts |= CAlgCryptMT1 | 			hc.cipheropts |= CAlgCryptMT1 | ||||||
|  | 		case "C_WANDERER": | ||||||
|  | 			log.Println("[extension arg = C_WANDERER]") | ||||||
|  | 			hc.cipheropts &= (0xFFFFFF00) | ||||||
|  | 			hc.cipheropts |= CAlgWanderer | ||||||
| 		case "H_SHA256": | 		case "H_SHA256": | ||||||
| 			log.Println("[extension arg = H_SHA256]") | 			log.Println("[extension arg = H_SHA256]") | ||||||
| 			hc.cipheropts &= (0xFFFF00FF) | 			hc.cipheropts &= (0xFFFF00FF) | ||||||
|  |  | ||||||
|  | @ -35,12 +35,12 @@ import ( | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var ( | var ( | ||||||
| 	version     string | 	version   string | ||||||
| 	gitCommit   string // set in -ldflags by build | 	gitCommit string // set in -ldflags by build | ||||||
| 	 | 
 | ||||||
| 	useSysLogin bool | 	useSysLogin bool | ||||||
| 	kcpMode string // set to a valid KCP BlockCrypt alg tag to use rather than TCP | 	kcpMode     string // set to a valid KCP BlockCrypt alg tag to use rather than TCP | ||||||
| 	 | 
 | ||||||
| 	// Log - syslog output (with no -d) | 	// Log - syslog output (with no -d) | ||||||
| 	Log *logger.Writer | 	Log *logger.Writer | ||||||
| ) | ) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue