Jiri Simsa | d7616c9 | 2015-03-24 23:44:30 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Vanadium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 5 | // Package crypto implements encryption and decryption interfaces intended for |
| 6 | // securing communication over VCs. |
| 7 | package crypto |
| 8 | |
Suharsh Sivakumar | dcc11d7 | 2015-05-11 12:19:20 -0700 | [diff] [blame] | 9 | import "v.io/x/ref/runtime/internal/lib/iobuf" |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 10 | |
| 11 | type Encrypter interface { |
| 12 | // Encrypt encrypts the provided plaintext data and returns the |
| 13 | // corresponding ciphertext slice (or nil if an error is returned). |
| 14 | // |
| 15 | // It always calls Release on plaintext and thus plaintext should not |
| 16 | // be used after calling Encrypt. |
| 17 | Encrypt(plaintext *iobuf.Slice) (ciphertext *iobuf.Slice, err error) |
| 18 | } |
| 19 | |
| 20 | type Decrypter interface { |
| 21 | // Decrypt decrypts the provided ciphertext slice and returns the |
| 22 | // corresponding plaintext (or nil if an error is returned). |
| 23 | // |
| 24 | // It always calls Release on ciphertext and thus ciphertext should not |
| 25 | // be used after calling Decrypt. |
| 26 | Decrypt(ciphertext *iobuf.Slice) (plaintext *iobuf.Slice, err error) |
| 27 | } |
| 28 | |
| 29 | type Crypter interface { |
| 30 | Encrypter |
| 31 | Decrypter |
Jungho Ahn | 19e84b2 | 2015-05-18 13:22:27 -0700 | [diff] [blame^] | 32 | // ChannelBinding returns a byte slice that is unique for the the |
Jason Hickey | 96d30e8 | 2014-11-13 07:40:00 -0800 | [diff] [blame] | 33 | // particular crypter (and the parties between which it is operating). |
Andres Erbsen | ffa4574 | 2014-08-13 10:13:11 -0700 | [diff] [blame] | 34 | // Having both parties assert out of the band that they are indeed |
| 35 | // participating in a connection with that channel binding value is |
| 36 | // sufficient to authenticate the data received through the crypter. |
| 37 | ChannelBinding() []byte |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 38 | String() string |
| 39 | } |