31 lines
		
	
	
		
			883 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			883 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package cc20p1305ssh
 | 
						|
 | 
						|
const (
 | 
						|
	/*
 | 
						|
		FullKeySize is 64, but OpenSSH only uses the first half for the (true) KeySize.
 | 
						|
		(Normally in ChaCha20Poly1305, the second half is used for "additional data".
 | 
						|
		OpenSSH keys do not have "additional data".)
 | 
						|
	*/
 | 
						|
	FullKeySize int = 64 // Generated by Poly1305...
 | 
						|
	KeySize     int = 32 // The first 32 of which are used by ChaCha20.
 | 
						|
	// And for clarity, aliases for the above.
 | 
						|
	Poly1305KeySize int = FullKeySize
 | 
						|
	ChaCha20KeySize int = KeySize
 | 
						|
	// IvSize is 0 because OpenSSH uses a fixed internal constant (see IV).
 | 
						|
	IvSize int = 0
 | 
						|
	// NonceSize is literally the only reason I need to do this. The only reason.
 | 
						|
	NonceSize int = 16
 | 
						|
	// TagLen is the length of the Poly1305 tag.
 | 
						|
	TagLen int = 16
 | 
						|
)
 | 
						|
 | 
						|
var (
 | 
						|
	// iv is the constant fixed IV.
 | 
						|
	iv []byte = []byte{
 | 
						|
		0x0, 0x0, 0x0, 0x0,
 | 
						|
		0x0, 0x0, 0x0, 0x0,
 | 
						|
		0x0, 0x0, 0x0, 0x0,
 | 
						|
		0x0, 0x0, 0x0, 0x0,
 | 
						|
	}
 | 
						|
)
 |