@@ -21,6 +21,7 @@ Please review third_party pinning scripts and patches for more details.
2121package api
2222
2323import (
24+ "math/big"
2425 "time"
2526
2627 "github.com/cloudflare/cfssl/csr"
@@ -32,7 +33,7 @@ type RegistrationRequest struct {
3233 // Name is the unique name of the identity
3334 Name string `json:"id" help:"Unique name of the identity"`
3435 // Type of identity being registered (e.g. "peer, app, user")
35- Type string `json:"type" def:"user " help:"Type of identity being registered (e.g. 'peer, app, user')"`
36+ Type string `json:"type" def:"client " help:"Type of identity being registered (e.g. 'peer, app, user')"`
3637 // Secret is an optional password. If not specified,
3738 // a random secret is generated. In both cases, the secret
3839 // is returned in the RegistrationResponse.
@@ -119,6 +120,61 @@ type RevocationRequest struct {
119120 Reason string `json:"reason,omitempty" opt:"r" help:"Reason for revocation"`
120121 // CAName is the name of the CA to connect to
121122 CAName string `json:"caname,omitempty" skip:"true"`
123+ // GenCRL specifies whether to generate a CRL
124+ GenCRL bool `def:"false" skip:"true" json:"gencrl,omitempty"`
125+ }
126+
127+ // RevocationResponse represents response from the server for a revocation request
128+ type RevocationResponse struct {
129+ // RevokedCerts is an array of certificates that were revoked
130+ RevokedCerts []RevokedCert
131+ // CRL is PEM-encoded certificate revocation list (CRL) that contains all unexpired revoked certificates
132+ CRL []byte
133+ }
134+
135+ // RevokedCert represents a revoked certificate
136+ type RevokedCert struct {
137+ // Serial number of the revoked certificate
138+ Serial string
139+ // AKI of the revoked certificate
140+ AKI string
141+ }
142+
143+ // GetTCertBatchRequest is input provided to identity.GetTCertBatch
144+ type GetTCertBatchRequest struct {
145+ // Number of TCerts in the batch.
146+ Count int `json:"count"`
147+ // The attribute names whose names and values are to be sealed in the issued TCerts.
148+ AttrNames []string `json:"attr_names,omitempty"`
149+ // EncryptAttrs denotes whether to encrypt attribute values or not.
150+ // When set to true, each issued TCert in the batch will contain encrypted attribute values.
151+ EncryptAttrs bool `json:"encrypt_attrs,omitempty"`
152+ // Certificate Validity Period. If specified, the value used
153+ // is the minimum of this value and the configured validity period
154+ // of the TCert manager.
155+ ValidityPeriod time.Duration `json:"validity_period,omitempty"`
156+ // The pre-key to be used for key derivation.
157+ PreKey string `json:"prekey"`
158+ // DisableKeyDerivation if true disables key derivation so that a TCert is not
159+ // cryptographically related to an ECert. This may be necessary when using an
160+ // HSM which does not support the TCert's key derivation function.
161+ DisableKeyDerivation bool `json:"disable_kdf,omitempty"`
162+ // CAName is the name of the CA to connect to
163+ CAName string `json:"caname,omitempty" skip:"true"`
164+ }
165+
166+ // GetTCertBatchResponse is the return value of identity.GetTCertBatch
167+ type GetTCertBatchResponse struct {
168+ ID * big.Int `json:"id"`
169+ TS time.Time `json:"ts"`
170+ Key []byte `json:"key"`
171+ TCerts []TCert `json:"tcerts"`
172+ }
173+
174+ // TCert encapsulates a signed transaction certificate and optionally a map of keys
175+ type TCert struct {
176+ Cert []byte `json:"cert"`
177+ Keys map [string ][]byte `json:"keys,omitempty"` //base64 encoded string as value
122178}
123179
124180// GetCAInfoRequest is request to get generic CA information
@@ -137,17 +193,134 @@ type GenCRLRequest struct {
137193
138194// GenCRLResponse represents a response to get CRL
139195type GenCRLResponse struct {
140- CRL string
196+ // CRL is PEM-encoded certificate revocation list (CRL) that contains requested unexpired revoked certificates
197+ CRL []byte
198+ }
199+
200+ // AddIdentityRequest represents the request to add a new identity to the
201+ // fabric-ca-server
202+ type AddIdentityRequest struct {
203+ ID string `json:"id" skip:"true"`
204+ Type string `json:"type" def:"user" help:"Type of identity being registered (e.g. 'peer, app, user')"`
205+ Affiliation string `json:"affiliation" help:"The identity's affiliation"`
206+ Attributes []Attribute `json:"attrs" mapstructure:"attrs" `
207+ MaxEnrollments int `json:"max_enrollments" mapstructure:"max_enrollments" def:"-1" help:"The maximum number of times the secret can be reused to enroll."`
208+ // Secret is an optional password. If not specified,
209+ // a random secret is generated. In both cases, the secret
210+ // is returned in the RegistrationResponse.
211+ Secret string `json:"secret,omitempty" mask:"password" help:"The enrollment secret for the identity being added"`
212+ CAName string `json:"caname,omitempty" skip:"true"`
213+ }
214+
215+ // ModifyIdentityRequest represents the request to modify an existing identity on the
216+ // fabric-ca-server
217+ type ModifyIdentityRequest struct {
218+ ID string `skip:"true"`
219+ Type string `json:"type" def:"user" help:"Type of identity being registered (e.g. 'peer, app, user')"`
220+ Affiliation string `json:"affiliation" help:"The identity's affiliation"`
221+ Attributes []Attribute `mapstructure:"attrs" json:"attrs"`
222+ MaxEnrollments int `mapstructure:"max_enrollments" json:"max_enrollments" def:"-1" help:"The maximum number of times the secret can be reused to enroll."`
223+ Secret string `json:"secret,omitempty" mask:"password" help:"The enrollment secret for the identity"`
224+ CAName string `json:"caname,omitempty" skip:"true"`
225+ }
226+
227+ // RemoveIdentityRequest represents the request to remove an existing identity from the
228+ // fabric-ca-server
229+ type RemoveIdentityRequest struct {
230+ ID string `skip:"true"`
231+ Force bool `json:"force"`
232+ CAName string `json:"caname,omitempty" skip:"true"`
233+ }
234+
235+ // GetIDResponse is the response from the GetIdentity call
236+ type GetIDResponse struct {
237+ ID string `json:"id" skip:"true"`
238+ Type string `json:"type" def:"user"`
239+ Affiliation string `json:"affiliation"`
240+ Attributes []Attribute `json:"attrs" mapstructure:"attrs" `
241+ MaxEnrollments int `json:"max_enrollments" mapstructure:"max_enrollments"`
242+ CAName string `json:"caname,omitempty"`
243+ }
244+
245+ // GetAllIDsResponse is the response from the GetAllIdentities call
246+ type GetAllIDsResponse struct {
247+ Identities []IdentityInfo `json:"identities"`
248+ CAName string `json:"caname,omitempty"`
249+ }
250+
251+ // IdentityResponse is the response from the any add/modify/remove identity call
252+ type IdentityResponse struct {
253+ ID string `json:"id" skip:"true"`
254+ Type string `json:"type,omitempty"`
255+ Affiliation string `json:"affiliation"`
256+ Attributes []Attribute `json:"attrs,omitempty" mapstructure:"attrs"`
257+ MaxEnrollments int `json:"max_enrollments,omitempty" mapstructure:"max_enrollments"`
258+ Secret string `json:"secret,omitempty"`
259+ CAName string `json:"caname,omitempty"`
260+ }
261+
262+ // IdentityInfo contains information about an identity
263+ type IdentityInfo struct {
264+ ID string `json:"id"`
265+ Type string `json:"type"`
266+ Affiliation string `json:"affiliation"`
267+ Attributes []Attribute `json:"attrs" mapstructure:"attrs"`
268+ MaxEnrollments int `json:"max_enrollments" mapstructure:"max_enrollments"`
269+ }
270+
271+ // AddAffiliationRequest represents the request to add a new affiliation to the
272+ // fabric-ca-server
273+ type AddAffiliationRequest struct {
274+ Name string `json:"name"`
275+ Force bool `json:"force"`
276+ CAName string `json:"caname,omitempty"`
277+ }
278+
279+ // ModifyAffiliationRequest represents the request to modify an existing affiliation on the
280+ // fabric-ca-server
281+ type ModifyAffiliationRequest struct {
282+ Name string
283+ NewName string `json:"name"`
284+ Force bool `json:"force"`
285+ CAName string `json:"caname,omitempty"`
286+ }
287+
288+ // RemoveAffiliationRequest represents the request to remove an existing affiliation from the
289+ // fabric-ca-server
290+ type RemoveAffiliationRequest struct {
291+ Name string
292+ Force bool `json:"force"`
293+ CAName string `json:"caname,omitempty"`
294+ }
295+
296+ // AffiliationResponse contains the response for get, add, modify, and remove an affiliation
297+ type AffiliationResponse struct {
298+ AffiliationInfo `mapstructure:",squash"`
299+ CAName string `json:"caname,omitempty"`
300+ }
301+
302+ // AffiliationInfo contains the affiliation name, child affiliation info, and identities
303+ // associated with this affiliation.
304+ type AffiliationInfo struct {
305+ Name string `json:"name"`
306+ Affiliations []AffiliationInfo `json:"affiliations,omitempty"`
307+ Identities []IdentityInfo `json:"identities,omitempty"`
141308}
142309
143310// CSRInfo is Certificate Signing Request (CSR) Information
144311type CSRInfo struct {
145- CN string `json:"CN"`
146- Names []csr.Name `json:"names,omitempty"`
147- Hosts []string `json:"hosts,omitempty"`
148- KeyRequest * csr.BasicKeyRequest `json:"key,omitempty"`
149- CA * csr.CAConfig `json:"ca,omitempty"`
150- SerialNumber string `json:"serial_number,omitempty"`
312+ CN string `json:"CN"`
313+ Names []csr.Name `json:"names,omitempty"`
314+ Hosts []string `json:"hosts,omitempty"`
315+ KeyRequest * BasicKeyRequest `json:"key,omitempty"`
316+ CA * csr.CAConfig `json:"ca,omitempty"`
317+ SerialNumber string `json:"serial_number,omitempty"`
318+ }
319+
320+ // BasicKeyRequest encapsulates size and algorithm for the key to be generated
321+ type BasicKeyRequest struct {
322+ Algo string `json:"algo" yaml:"algo"`
323+ Size int `json:"size" yaml:"size"`
151324}
152325
153326// Attribute is a name and value pair
@@ -183,3 +356,10 @@ func (ar *AttributeRequest) GetName() string {
183356func (ar * AttributeRequest ) IsRequired () bool {
184357 return ! ar .Optional
185358}
359+
360+ // NewBasicKeyRequest returns the BasicKeyRequest object that is constructed
361+ // from the object returned by the csr.NewBasicKeyRequest() function
362+ func NewBasicKeyRequest () * BasicKeyRequest {
363+ bkr := csr .NewBasicKeyRequest ()
364+ return & BasicKeyRequest {Algo : bkr .A , Size : bkr .S }
365+ }
0 commit comments