| 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 { |
| 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 when in SignRequest. |
| 57 long signRequestId; |
| 58 |
| 59 // The type of code requested, PIN or PUK. Default is PIN. |
| 60 PinRequestType? requestType; |
| 61 |
| 62 // The error template displayed for user. This should be set if the previous |
| 63 // request failed, to notify the user of the failure reason. |
| 64 PinRequestErrorType? errorType; |
| 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, |
| 68 // instead StopPinRequestDetails will be called 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 when 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. If some error occurred, it will be provided using |
| 87 // chrome.runtime.lastError variable. The error can be: |
| 88 // OTHER_FLOW_IN_PROGRESS - A request PIN flow is ongoing already. |
| 89 // INVALID_ID - The value of signRequestId is invalid. |
| 90 // UNEXPECTED_ERROR - Some unexpected error occurred in the code. |
| 91 DOMString? userInput; |
| 92 }; |
| 93 |
| 94 // A callback called when the dialog gets resolved with the user input, or |
| 95 // when the dialog request finishes unsuccessfully (e.g. the dialog was |
| 96 // canceled by the user or was not allowed to be shown). |
| 97 callback RequestPinCallback = void (optional PinResponseDetails details); |
| 98 |
| 99 // The callback to be used by Chrome to send to the extension the status from |
| 100 // their request to close PIN dialog for user. |
| 101 callback StopPinRequestCallback = void (); |
| 102 |
| 39 // The callback provided by the extension that Chrome uses to report back | 103 // The callback provided by the extension that Chrome uses to report back |
| 40 // rejected certificates. See <code>CertificatesCallback</code>. | 104 // rejected certificates. See <code>CertificatesCallback</code>. |
| 41 callback ResultCallback = void (ArrayBuffer[] rejectedCertificates); | 105 callback ResultCallback = void (ArrayBuffer[] rejectedCertificates); |
| 42 | 106 |
| 43 // If no error occurred, this function must be called with the signature of | 107 // If no error occurred, this function must be called with the signature of |
| 44 // the digest using the private key of the requested certificate. | 108 // 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 | 109 // 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 | 110 // 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 | 111 // 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. | 112 // 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 | 133 // certificate provided by this extension in reply to an |
| 70 // $(ref:onCertificatesRequested) event. | 134 // $(ref:onCertificatesRequested) event. |
| 71 // The extension must sign the data in <code>request</code> using the | 135 // The extension must sign the data in <code>request</code> using the |
| 72 // appropriate algorithm and private key and return it by calling | 136 // appropriate algorithm and private key and return it by calling |
| 73 // <code>reportCallback</code>. <code>reportCallback</code> must be called | 137 // <code>reportCallback</code>. <code>reportCallback</code> must be called |
| 74 // exactly once. | 138 // exactly once. |
| 75 // |request|: Contains the details about the sign request. | 139 // |request|: Contains the details about the sign request. |
| 76 static void onSignDigestRequested(SignRequest request, | 140 static void onSignDigestRequested(SignRequest request, |
| 77 SignCallback reportCallback); | 141 SignCallback reportCallback); |
| 78 }; | 142 }; |
| 143 |
| 144 interface Functions { |
| 145 // Requests the PIN from user. Only one ongoing request at a time is |
| 146 // allowed. The requests issued while other flow is ongoing are rejected. |
| 147 // It's extension's responsibility to try again later if other flow is in |
| 148 // progress. |
| 149 static void requestPin(RequestPinDetails details, |
| 150 RequestPinCallback callback); |
| 151 |
| 152 // Stops the pin request started by $(ref:requestPin) function. |
| 153 static void stopPinRequest(StopPinRequestDetails details, |
| 154 StopPinRequestCallback callback); |
| 155 }; |
| 79 }; | 156 }; |
| OLD | NEW |