Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 1 | // 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. |
| 11 | package wire |
| 12 | |
Asim Shankar | e5de89e | 2014-06-01 17:43:21 -0700 | [diff] [blame^] | 13 | import "veyron2/security" |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 14 | |
| 15 | const ( |
| 16 | keyCurveP256 keyCurve = 0 |
| 17 | // ChainSeparator is used to join blessing names to form a blessing chain name. |
| 18 | ChainSeparator = "/" |
| 19 | // UntrustedIDProviderPrefix is the prefix added to identity names |
| 20 | // when the identity provider is unknown (i.e., neither trusted nor |
| 21 | // mistrusted). |
| 22 | UntrustedIDProviderPrefix = "untrusted/" |
| 23 | ) |
| 24 | |
| 25 | type keyCurve byte |
| 26 | |
| 27 | // PublicKey represents an ECDSA PublicKey. |
| 28 | type PublicKey struct { |
| 29 | // Curve identifies the curve of an ECDSA PublicKey. |
| 30 | Curve keyCurve |
| 31 | // XY is the marshaled form of a point on the curve using the format specified |
| 32 | // in section 4.3.6 of ANSI X9.62. |
| 33 | XY []byte |
| 34 | } |
| 35 | |
| 36 | // Signature represents an ECDSA signature. |
| 37 | type Signature struct { |
| 38 | // R, S specify the pair of integers that make up an ECDSA signature. |
| 39 | R, S []byte |
| 40 | } |
| 41 | |
| 42 | // Caveat represents a veyron2/security.ServiceCaveat. |
| 43 | type Caveat struct { |
| 44 | // Service is a pattern identifying the services that the caveat encoded in Bytes |
| 45 | // is bound to. |
| 46 | Service security.PrincipalPattern |
| 47 | // Bytes is a serialized representation of the embedded caveat. |
| 48 | Bytes []byte |
| 49 | } |
| 50 | |
| 51 | // Certificate is a signed assertion binding a name to a public key under a certain set |
| 52 | // of caveats. The issuer of a Certificate is the principal that possesses the private key |
| 53 | // under which the Certificate was signed. The Certificate's signature is over the contents |
| 54 | // of the Certificate along with the Signature of the issuer. |
| 55 | type Certificate struct { |
| 56 | // Name specified in the certificate, e.g., Alice, Bob. Name must not have the |
| 57 | // character "/". |
| 58 | Name string |
| 59 | // PublicKey is the ECDSA public key associated with the Certificate. |
| 60 | PublicKey PublicKey |
| 61 | // Caveats under which the certificate is valid. |
| 62 | Caveats []Caveat |
| 63 | // Signature of the contents of the certificate. |
| 64 | Signature Signature |
| 65 | } |
| 66 | |
| 67 | // ChainPublicID represents the chain implementation of PublicIDs from veyron/runtimes/google/security. |
| 68 | // It consists of a chain of certificates such that each certificate is signed using the private key |
| 69 | // of the previous certificate (i.e., issuer). The certificate's signature is over its contents along |
| 70 | // with the signature of the issuer certificate (this is done to bind this certificate to the issuer |
| 71 | // chain). The first certificate of the chain is "self signed". The last certificate's public key is |
| 72 | // considered the PublicID's public key. The chain of certificates, if valid, effectively binds a chain |
| 73 | // of names to the PublicID's public key. |
| 74 | type ChainPublicID struct { |
| 75 | // Certificates specifies the chain of certificates for the PublicID. |
| 76 | Certificates []Certificate |
| 77 | } |
| 78 | |
| 79 | // ChainPrivateID represents the chain implementation of PrivateIDs from veyron/runtimes/google/security. |
| 80 | type ChainPrivateID struct { |
| 81 | // PublicID associated with the PrivateID. |
Asim Shankar | e5de89e | 2014-06-01 17:43:21 -0700 | [diff] [blame^] | 82 | PublicID ChainPublicID |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 83 | // Secret represents the secret integer that together with an ECDSA public key makes up the |
| 84 | // corresponding private key. |
| 85 | Secret []byte |
| 86 | } |