Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Use this API to expose certificates to the platform which can use these | 5 // Use this API to expose certificates to the platform which can use these |
| 6 // certificates for TLS authentications. | 6 // certificates for TLS authentications. |
| 7 namespace certificateProvider { | 7 namespace certificateProvider { |
| 8 enum Hash { | 8 enum Hash { |
| 9 MD5_SHA1, | 9 MD5_SHA1, |
| 10 SHA1, | 10 SHA1, |
| 11 SHA256, | 11 SHA256, |
| 12 SHA384, | 12 SHA384, |
| 13 SHA512 | 13 SHA512 |
| 14 }; | 14 }; |
| 15 | 15 |
| 16 enum PinRequestType { | |
|
Devlin
2016/11/01 16:24:30
Document these enums
igorcov
2016/11/04 15:51:42
Done.
| |
| 17 PIN, | |
| 18 PUK | |
| 19 }; | |
| 20 | |
| 21 enum PinRequestErrorType { | |
| 22 INVALID_PIN, | |
| 23 INVALID_PUK, | |
| 24 MAX_ATTEMPTS_EXCEEDED, | |
| 25 UNKNOWN_ERROR | |
| 26 }; | |
| 27 | |
| 16 [noinline_doc] dictionary CertificateInfo { | 28 [noinline_doc] dictionary CertificateInfo { |
| 17 // Must be the DER encoding of a X.509 certificate. Currently, only | 29 // Must be the DER encoding of a X.509 certificate. Currently, only |
| 18 // certificates of RSA keys are supported. | 30 // certificates of RSA keys are supported. |
| 19 ArrayBuffer certificate; | 31 ArrayBuffer certificate; |
| 20 | 32 |
| 21 // Must be set to all hashes supported for this certificate. This extension | 33 // Must be set to all hashes supported for this certificate. This extension |
| 22 // will only be asked for signatures of digests calculated with one of these | 34 // will only be asked for signatures of digests calculated with one of these |
| 23 // hash algorithms. This should be in order of decreasing hash preference. | 35 // hash algorithms. This should be in order of decreasing hash preference. |
| 24 Hash[] supportedHashes; | 36 Hash[] supportedHashes; |
| 25 }; | 37 }; |
| 26 | 38 |
| 27 [noinline_doc] dictionary SignRequest { | 39 [noinline_doc] dictionary SignRequest { |
| 40 // The unique ID to be used by the extension should it need to call a method | |
| 41 // that requires it, e.g. requestPin. | |
| 42 long signRequestId; | |
| 43 | |
| 28 // The digest that must be signed. | 44 // The digest that must be signed. |
| 29 ArrayBuffer digest; | 45 ArrayBuffer digest; |
| 30 | 46 |
| 31 // Refers to the hash algorithm that was used to create <code>digest</code>. | 47 // Refers to the hash algorithm that was used to create <code>digest</code>. |
| 32 Hash hash; | 48 Hash hash; |
| 33 | 49 |
| 34 // The DER encoding of a X.509 certificate. The extension must sign | 50 // The DER encoding of a X.509 certificate. The extension must sign |
| 35 // <code>digest</code> using the associated private key. | 51 // <code>digest</code> using the associated private key. |
| 36 ArrayBuffer certificate; | 52 ArrayBuffer certificate; |
| 37 }; | 53 }; |
| 38 | 54 |
| 55 dictionary RequestPinDetails { | |
| 56 // The ID given by Chrome in SignRequest. | |
| 57 long signRequestId; | |
| 58 | |
| 59 // The type of code requested. Default is PIN. | |
| 60 PinRequestType? requestType; | |
| 61 | |
| 62 // The error template displayed to the user. This should be set if the | |
| 63 // previous request failed, to notify the user of the failure reason. | |
| 64 PinRequestErrorType? errorType; | |
|
Devlin
2016/11/01 16:24:30
Why don't we allow the extension to set the error
igorcov
2016/11/04 15:51:42
This proposal didn't pass security review. Basical
| |
| 65 | |
| 66 // The number of attempts left. This is provided so that any UI can present | |
| 67 // this information to the user. Chrome is not expected to enforce this, | |
|
Devlin
2016/11/01 16:24:30
This still strikes me as very odd - why doesn't Ch
igorcov
2016/11/04 15:51:42
We don't want to limit the behavior of the extensi
| |
| 68 // instead stopPinRequest should be called by the extension with | |
| 69 // errorType = MAX_ATTEMPTS_EXCEEDED when the number of pin requests is | |
| 70 // exceeded. | |
| 71 long? attemptsLeft; | |
| 72 }; | |
| 73 | |
| 74 dictionary StopPinRequestDetails { | |
| 75 // The ID given by Chrome in SignRequest. | |
| 76 long signRequestId; | |
| 77 | |
| 78 // The error template. If present it is displayed to user. Intended to | |
| 79 // contain the reason for stopping the flow if it was caused by an error, | |
| 80 // e.g. MAX_ATTEMPTS_EXCEEDED. | |
| 81 PinRequestErrorType? errorType; | |
| 82 }; | |
| 83 | |
| 84 dictionary PinResponseDetails { | |
| 85 // The code provided by the user. Empty if user closed the dialog or some | |
| 86 // other error occurred. | |
| 87 DOMString? userInput; | |
| 88 }; | |
| 89 | |
| 90 callback RequestPinCallback = void (optional PinResponseDetails details); | |
| 91 | |
| 92 callback StopPinRequestCallback = void (); | |
| 93 | |
| 39 // The callback provided by the extension that Chrome uses to report back | 94 // The callback provided by the extension that Chrome uses to report back |
| 40 // rejected certificates. See <code>CertificatesCallback</code>. | 95 // rejected certificates. See <code>CertificatesCallback</code>. |
| 41 callback ResultCallback = void (ArrayBuffer[] rejectedCertificates); | 96 callback ResultCallback = void (ArrayBuffer[] rejectedCertificates); |
| 42 | 97 |
| 43 // If no error occurred, this function must be called with the signature of | 98 // If no error occurred, this function must be called with the signature of |
| 44 // the digest using the private key of the requested certificate. | 99 // the digest using the private key of the requested certificate. |
| 45 // For an RSA key, the signature must be a PKCS#1 signature. The extension | 100 // For an RSA key, the signature must be a PKCS#1 signature. The extension |
| 46 // is responsible for prepending the DigestInfo prefix and adding PKCS#1 | 101 // is responsible for prepending the DigestInfo prefix and adding PKCS#1 |
| 47 // padding. If an <code>MD5_SHA1</code> hash is to be signed, the extension | 102 // padding. If an <code>MD5_SHA1</code> hash is to be signed, the extension |
| 48 // must not prepend a DigestInfo prefix but only add PKCS#1 padding. | 103 // must not prepend a DigestInfo prefix but only add PKCS#1 padding. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 69 // certificate provided by this extension in reply to an | 124 // certificate provided by this extension in reply to an |
| 70 // $(ref:onCertificatesRequested) event. | 125 // $(ref:onCertificatesRequested) event. |
| 71 // The extension must sign the data in <code>request</code> using the | 126 // The extension must sign the data in <code>request</code> using the |
| 72 // appropriate algorithm and private key and return it by calling | 127 // appropriate algorithm and private key and return it by calling |
| 73 // <code>reportCallback</code>. <code>reportCallback</code> must be called | 128 // <code>reportCallback</code>. <code>reportCallback</code> must be called |
| 74 // exactly once. | 129 // exactly once. |
| 75 // |request|: Contains the details about the sign request. | 130 // |request|: Contains the details about the sign request. |
| 76 static void onSignDigestRequested(SignRequest request, | 131 static void onSignDigestRequested(SignRequest request, |
| 77 SignCallback reportCallback); | 132 SignCallback reportCallback); |
| 78 }; | 133 }; |
| 134 | |
| 135 interface Functions { | |
| 136 // Requests the PIN from the user. Only one ongoing request at a time is | |
| 137 // allowed. The requests issued while another flow is ongoing are rejected. | |
| 138 // It's the extension's responsibility to try again later if another flow is | |
| 139 // in progress. | |
| 140 // |details|: Contains the details about the requested dialog. | |
| 141 // |callback|: Is called when the dialog is resolved with the user input, or | |
| 142 // when the dialog request finishes unsuccessfully (e.g. the dialog was | |
| 143 // canceled by the user or was not allowed to be shown). | |
| 144 static void requestPin(RequestPinDetails details, | |
| 145 RequestPinCallback callback); | |
| 146 | |
| 147 // Stops the pin request started by the $(ref:requestPin) function. | |
| 148 // |details|: Contains the details about the reason for stopping the | |
| 149 // request flow. | |
| 150 // |callback|: To be used by Chrome to send to the extension the status from | |
| 151 // their request to close PIN dialog for user. | |
| 152 static void stopPinRequest(StopPinRequestDetails details, | |
| 153 StopPinRequestCallback callback); | |
| 154 }; | |
| 79 }; | 155 }; |
| OLD | NEW |