blob: d09cb8cef8c3c74e01a6abec389fce6d740d74e0 [file] [log] [blame]
Jiri Simsa5293dcb2014-05-10 09:56:38 -07001// Package wire provides the types for representing ECDSA public keys, ECDSA
2// Signatures, Caveats, and the various Identity implementations (described in
3// veyron/runtimes/google/security) on the wire. The package also provides methods
4// for encoding (decoding) the corresponding Go types to (from) wire types.
5// While the wire types are themselves described as Go structs, they only make
6// use of primitive types and therefore can be used in any programming language
7// (assuming the language understands VOM). For example, instead of using the
8// Go-specific crypto.ecdsa.PublicKey interfaces for describing ECDSA public keys,
9// we define a publicKey wire type struct that only contains the primitive values
10// that make up the public key.
11package wire
12
13import (
14 "veyron2/security"
15)
16
17const (
18 keyCurveP256 keyCurve = 0
19 // ChainSeparator is used to join blessing names to form a blessing chain name.
20 ChainSeparator = "/"
21 // UntrustedIDProviderPrefix is the prefix added to identity names
22 // when the identity provider is unknown (i.e., neither trusted nor
23 // mistrusted).
24 UntrustedIDProviderPrefix = "untrusted/"
25)
26
27type keyCurve byte
28
29// PublicKey represents an ECDSA PublicKey.
30type PublicKey struct {
31 // Curve identifies the curve of an ECDSA PublicKey.
32 Curve keyCurve
33 // XY is the marshaled form of a point on the curve using the format specified
34 // in section 4.3.6 of ANSI X9.62.
35 XY []byte
36}
37
38// Signature represents an ECDSA signature.
39type Signature struct {
40 // R, S specify the pair of integers that make up an ECDSA signature.
41 R, S []byte
42}
43
44// Caveat represents a veyron2/security.ServiceCaveat.
45type Caveat struct {
46 // Service is a pattern identifying the services that the caveat encoded in Bytes
47 // is bound to.
48 Service security.PrincipalPattern
49 // Bytes is a serialized representation of the embedded caveat.
50 Bytes []byte
51}
52
53// Certificate is a signed assertion binding a name to a public key under a certain set
54// of caveats. The issuer of a Certificate is the principal that possesses the private key
55// under which the Certificate was signed. The Certificate's signature is over the contents
56// of the Certificate along with the Signature of the issuer.
57type Certificate struct {
58 // Name specified in the certificate, e.g., Alice, Bob. Name must not have the
59 // character "/".
60 Name string
61 // PublicKey is the ECDSA public key associated with the Certificate.
62 PublicKey PublicKey
63 // Caveats under which the certificate is valid.
64 Caveats []Caveat
65 // Signature of the contents of the certificate.
66 Signature Signature
67}
68
69// ChainPublicID represents the chain implementation of PublicIDs from veyron/runtimes/google/security.
70// It consists of a chain of certificates such that each certificate is signed using the private key
71// of the previous certificate (i.e., issuer). The certificate's signature is over its contents along
72// with the signature of the issuer certificate (this is done to bind this certificate to the issuer
73// chain). The first certificate of the chain is "self signed". The last certificate's public key is
74// considered the PublicID's public key. The chain of certificates, if valid, effectively binds a chain
75// of names to the PublicID's public key.
76type ChainPublicID struct {
77 // Certificates specifies the chain of certificates for the PublicID.
78 Certificates []Certificate
79}
80
81// ChainPrivateID represents the chain implementation of PrivateIDs from veyron/runtimes/google/security.
82type ChainPrivateID struct {
83 // PublicID associated with the PrivateID.
84 PublicID *ChainPublicID
85 // Secret represents the secret integer that together with an ECDSA public key makes up the
86 // corresponding private key.
87 Secret []byte
88}
89
90// Blessing is a signed assertion binding a name to a public key under a certain set
91// of caveats. The aforesaid public key is also called the "public key being blessed".
92// The issuer of a blessing is the principal that possesses the private key
93// under which the Blessing was signed. The PublicID of the issuer is also linked to
94// from the blessing.
95type Blessing struct {
96 // Blessor is the PublicID of the issuer of the blessing. It is nil if the blessing
97 // is self-signed, i.e, the public key being blessed and the private key signing
98 // the blessing correspond.
99 Blessor *TreePublicID
100 // Name specified in the blessing, e.g., Alice, Bob. Name must not have the
101 // characters "/" or "#".
102 Name string
103 // Caveats under which the blessing is valid.
104 Caveats []Caveat
105 // Signature of the contents of the blessing along with the public key being
106 // blessed.
107 Signature Signature
108}
109
110// TreePublicID represents the tree implementation of PublicIDs from veyron/runtimes/google/security.
111// It consists of a public key and a list of blessings binding different names to the public key.
112// For each blessing, the blesser's PublicID (which is linked to from the blessing) may in turn
113// have blessings of its own thus resulting in a tree of blessings. The blessings at the leaves
114// of the tree are "self signed". This blessing tree effectively binds a tree of names to the
115// PublicID depending on which blessings are valid.
116type TreePublicID struct {
117 // PublicKey is the ECDSA public key associated with the PublicID.
118 PublicKey PublicKey
119 // Blessings is the list of blessings for the aforesaid public key.
120 Blessings []Blessing
121}
122
123// TreePrivateID represents the tree implementation of PrivateIDs from veyron/runtimes/google/security.
124type TreePrivateID struct {
125 // PublicID associated with the PrivateID.
126 PublicID *TreePublicID
127 // Secret represents the secret integer that together with an ECDSA public key makes up the
128 // corresponding private key.
129 Secret []byte
130}