MCPcopy
hub / github.com/nirui/sshwifty / createCipher

Method createCipher

application/controller/socket.go:250–278  ·  view source on GitHub ↗
(key []byte)

Source from the content-addressed store, hash-verified

248}
249
250func (s socket) createCipher(key []byte) (cipher.AEAD, cipher.AEAD, error) {
251 readCipher, readCipherErr := aes.NewCipher(key)
252
253 if readCipherErr != nil {
254 return nil, nil, readCipherErr
255 }
256
257 writeCipher, writeCipherErr := aes.NewCipher(key)
258
259 if writeCipherErr != nil {
260 return nil, nil, writeCipherErr
261 }
262
263 gcmRead, gcmReadErr := cipher.NewGCMWithNonceSize(
264 readCipher, socketGCMStandardNonceSize)
265
266 if gcmReadErr != nil {
267 return nil, nil, gcmReadErr
268 }
269
270 gcmWrite, gcmWriteErr := cipher.NewGCMWithNonceSize(
271 writeCipher, socketGCMStandardNonceSize)
272
273 if gcmWriteErr != nil {
274 return nil, nil, gcmWriteErr
275 }
276
277 return gcmRead, gcmWrite, nil
278}
279
280func (s socket) privateKey() string {
281 if len(s.commonCfg.SharedKey) > 0 {

Callers 1

GetMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected