 9bdcbe0447
			
		
	
	9bdcbe0447
	
	
	
		
			
			Major integrations and fixes: - Added BACKBEAT SDK integration for P2P operation timing - Implemented beat-aware status tracking for distributed operations - Added Docker secrets support for secure license management - Resolved KACHING license validation via HTTPS/TLS - Updated docker-compose configuration for clean stack deployment - Disabled rollback policies to prevent deployment failures - Added license credential storage (CHORUS-DEV-MULTI-001) Technical improvements: - BACKBEAT P2P operation tracking with phase management - Enhanced configuration system with file-based secrets - Improved error handling for license validation - Clean separation of KACHING and CHORUS deployment stacks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
		
			
				
	
	
		
			82 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			82 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2016 The Go Authors. All rights reserved.
 | |
| // Use of this source code is governed by a BSD-style
 | |
| // license that can be found in the LICENSE file.
 | |
| 
 | |
| package chacha20poly1305
 | |
| 
 | |
| import (
 | |
| 	"encoding/binary"
 | |
| 
 | |
| 	"golang.org/x/crypto/chacha20"
 | |
| 	"golang.org/x/crypto/internal/alias"
 | |
| 	"golang.org/x/crypto/internal/poly1305"
 | |
| )
 | |
| 
 | |
| func writeWithPadding(p *poly1305.MAC, b []byte) {
 | |
| 	p.Write(b)
 | |
| 	if rem := len(b) % 16; rem != 0 {
 | |
| 		var buf [16]byte
 | |
| 		padLen := 16 - rem
 | |
| 		p.Write(buf[:padLen])
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func writeUint64(p *poly1305.MAC, n int) {
 | |
| 	var buf [8]byte
 | |
| 	binary.LittleEndian.PutUint64(buf[:], uint64(n))
 | |
| 	p.Write(buf[:])
 | |
| }
 | |
| 
 | |
| func (c *chacha20poly1305) sealGeneric(dst, nonce, plaintext, additionalData []byte) []byte {
 | |
| 	ret, out := sliceForAppend(dst, len(plaintext)+poly1305.TagSize)
 | |
| 	ciphertext, tag := out[:len(plaintext)], out[len(plaintext):]
 | |
| 	if alias.InexactOverlap(out, plaintext) {
 | |
| 		panic("chacha20poly1305: invalid buffer overlap")
 | |
| 	}
 | |
| 
 | |
| 	var polyKey [32]byte
 | |
| 	s, _ := chacha20.NewUnauthenticatedCipher(c.key[:], nonce)
 | |
| 	s.XORKeyStream(polyKey[:], polyKey[:])
 | |
| 	s.SetCounter(1) // set the counter to 1, skipping 32 bytes
 | |
| 	s.XORKeyStream(ciphertext, plaintext)
 | |
| 
 | |
| 	p := poly1305.New(&polyKey)
 | |
| 	writeWithPadding(p, additionalData)
 | |
| 	writeWithPadding(p, ciphertext)
 | |
| 	writeUint64(p, len(additionalData))
 | |
| 	writeUint64(p, len(plaintext))
 | |
| 	p.Sum(tag[:0])
 | |
| 
 | |
| 	return ret
 | |
| }
 | |
| 
 | |
| func (c *chacha20poly1305) openGeneric(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) {
 | |
| 	tag := ciphertext[len(ciphertext)-16:]
 | |
| 	ciphertext = ciphertext[:len(ciphertext)-16]
 | |
| 
 | |
| 	var polyKey [32]byte
 | |
| 	s, _ := chacha20.NewUnauthenticatedCipher(c.key[:], nonce)
 | |
| 	s.XORKeyStream(polyKey[:], polyKey[:])
 | |
| 	s.SetCounter(1) // set the counter to 1, skipping 32 bytes
 | |
| 
 | |
| 	p := poly1305.New(&polyKey)
 | |
| 	writeWithPadding(p, additionalData)
 | |
| 	writeWithPadding(p, ciphertext)
 | |
| 	writeUint64(p, len(additionalData))
 | |
| 	writeUint64(p, len(ciphertext))
 | |
| 
 | |
| 	ret, out := sliceForAppend(dst, len(ciphertext))
 | |
| 	if alias.InexactOverlap(out, ciphertext) {
 | |
| 		panic("chacha20poly1305: invalid buffer overlap")
 | |
| 	}
 | |
| 	if !p.Verify(tag) {
 | |
| 		for i := range out {
 | |
| 			out[i] = 0
 | |
| 		}
 | |
| 		return nil, errOpen
 | |
| 	}
 | |
| 
 | |
| 	s.XORKeyStream(out, ciphertext)
 | |
| 	return ret, nil
 | |
| }
 |