aboutsummaryrefslogtreecommitdiff
path: root/cc/proto/aes_gcm.proto
blob: 2551aa4ed0213fdb930426d30282a001c98f771f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////

syntax = "proto3";

package google.crypto.tink;

option java_package = "com.google.crypto.tink.proto";
option java_multiple_files = true;
option go_package = "github.com/google/tink/go/proto/aes_gcm_go_proto";
option objc_class_prefix = "TINKPB";

message AesGcmKeyFormat {
  uint32 key_size = 2;
  uint32 version = 3;
}

// key_type: type.googleapis.com/google.crypto.tink.AesGcmKey
//
// A AesGcmKey is an AEAD key. Mathematically, it represents the functions
// Encrypt and Decrypt which we define in the following.
//
// First, Tink computes a "output prefix" OP by considering the
// "OutputPrefixType" message in Keyset.Key and the ID of the key using the
// Tink function "AEAD-OutputPrefix": (AesGcmKeys must always be stored in a
// keyset).
//
// AEAD-OutputPrefix(output_prefix_type, id):
//     if output_prefix_type == RAW:
//       return "";
//     if output_prefix_type == TINK:
//       return 0x01 + BigEndian(id)
//     if output_prefix_type == CRUNCHY:
//       return 0x00 + BigEndian(id)
//
// Then, the function defined by this is defined as:
// [GCM], Section 5.2.1:
//  * "Encrypt" maps a plaintext P and associated data A to a ciphertext given
//    by the concatenation OP || IV || C || T. In addition to [GCM], Tink
//    has the following restriction: IV is a uniformly random initialization
//    vector of length 12 bytes and T is restricted to 16 bytes.
//
//  * If OP matches the result of AEAD-OutputPrefix, then "Decrypt" maps the
//    input OP || IV || C || T and A to the the output P in the manner as
//    described in [GCM], Section 5.2.2. If OP does not match, then "Decrypt"
//    returns an error.
// [GCM]: NIST Special Publication 800-38D: Recommendation for Block Cipher
// Modes of Operation: Galois/Counter Mode (GCM) and GMAC.
// http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf.

message AesGcmKey {
  uint32 version = 1;
  bytes key_value = 3;
}