|
1 | 1 | import { Constrained, Uint16 } from "../src/dep.ts"; |
2 | 2 | import { Enum } from "../src/enum.js"; |
3 | | -import type { Handshake } from "../src/handshaketype.js"; |
4 | 3 |
|
5 | 4 | /** |
6 | 5 | * Enumeration of signature schemes as defined in RFC 8446. |
@@ -62,138 +61,87 @@ export class SignatureScheme extends Enum { |
62 | 61 | get Uint16(): Uint16; |
63 | 62 |
|
64 | 63 | /** |
65 | | - * Generates a CertificateVerify object. |
66 | | - * @param {Uint8Array} clientHelloMsg - Client Hello message. |
67 | | - * @param {Uint8Array} serverHelloMsg - Server Hello message. |
68 | | - * @param {Uint8Array} encryptedExtensionsMsg - encryptedExtensions message |
69 | | - * @param {Uint8Array} certificateMsg - Certificate message. |
70 | | - * @param {CryptoKey} RSAprivateKey - RSA private key. |
71 | | - * @returns {Promise<CertificateVerify>} CertificateVerify object. |
| 64 | + * Creates a CertificateVerify handshake instance. |
| 65 | + * @param clientHelloMsg The ClientHello message. |
| 66 | + * @param serverHelloMsg The ServerHello message. |
| 67 | + * @param encryptedExtensionsMsg The EncryptedExtensions message. |
| 68 | + * @param certificateMsg The Certificate message. |
| 69 | + * @param RSAprivateKey The RSA private key. |
| 70 | + * @param sha The SHA variant (256, 384, or 512). |
72 | 71 | */ |
73 | 72 | certificateVerify( |
74 | 73 | clientHelloMsg: Uint8Array, |
75 | 74 | serverHelloMsg: Uint8Array, |
76 | 75 | encryptedExtensionsMsg: Uint8Array, |
77 | 76 | certificateMsg: Uint8Array, |
78 | | - RSAprivateKey: CryptoKey |
| 77 | + RSAprivateKey: CryptoKey, |
| 78 | + sha: number, |
79 | 79 | ): Promise<CertificateVerify>; |
80 | | - |
81 | | - /** |
82 | | - * Generates a CertificateVerify Handshake object. |
83 | | - * @param {Uint8Array} clientHelloMsg - Client Hello message. |
84 | | - * @param {Uint8Array} serverHelloMsg - Server Hello message. |
85 | | - * @param {Uint8Array} encryptedExtensionsMsg - encryptedExtensions message |
86 | | - * @param {Uint8Array} certificateMsg - Certificate message. |
87 | | - * @param {CryptoKey} RSAprivateKey - RSA private key. |
88 | | - * @returns {Promise<Handshake>} Handshake of CertificateVerify object. |
89 | | - */ |
90 | | - certificateVerifyMsg( |
91 | | - clientHelloMsg: Uint8Array, |
92 | | - serverHelloMsg: Uint8Array, |
93 | | - encryptedExtensionsMsg: Uint8Array, |
94 | | - certificateMsg: Uint8Array, |
95 | | - RSAprivateKey: CryptoKey |
96 | | - ): Promise<Handshake>; |
97 | 80 | } |
98 | 81 |
|
99 | 82 | /** |
100 | | - * Represents a CertificateVerify structure. |
| 83 | + * Represents a CertificateVerify message. |
101 | 84 | */ |
102 | | -export class CertificateVerify extends Uint8Array { |
103 | | - /** The signature algorithm used. */ |
104 | | - algorithm: SignatureScheme; |
105 | | - |
106 | | - /** The signature. */ |
107 | | - signature: Uint8Array; |
108 | | - |
| 85 | +export declare class CertificateVerify extends Uint8Array { |
109 | 86 | /** |
110 | | - * Parses a byte array into a CertificateVerify object. |
111 | | - * @param {Uint8Array} array - The byte array to parse. |
112 | | - * @returns {CertificateVerify} The parsed CertificateVerify object. |
| 87 | + * Creates a CertificateVerify instance from an array. |
| 88 | + * @param array The input array. |
113 | 89 | */ |
114 | | - static from(array: Uint8Array): CertificateVerify; |
| 90 | + static fromMsg(array: Uint8Array): CertificateVerify; |
115 | 91 |
|
116 | | - /** |
117 | | - * Constructs a new CertificateVerify object. |
118 | | - * @param {SignatureScheme} signatureScheme - The signature scheme. |
119 | | - * @param {Uint8Array} signature - The signature. |
120 | | - */ |
121 | 92 | constructor(signatureScheme: SignatureScheme, signature: Uint8Array); |
| 93 | + |
| 94 | + algorithm: SignatureScheme; |
| 95 | + signature: Uint8Array; |
122 | 96 | } |
123 | 97 |
|
124 | 98 | /** |
125 | | - * Represents a constrained signature. |
| 99 | + * Represents a constrained Signature. |
126 | 100 | */ |
127 | | -export class Signature extends Constrained { |
128 | | - /** The raw opaque signature data. */ |
129 | | - opaque: Uint8Array; |
130 | | - |
| 101 | +export declare class Signature extends Constrained { |
131 | 102 | /** |
132 | | - * Parses a byte array into a Signature object. |
133 | | - * @param {Uint8Array} array - The byte array to parse. |
134 | | - * @returns {Signature} The parsed Signature object. |
| 103 | + * Creates a Signature instance from an array. |
| 104 | + * @param array The input array. |
135 | 105 | */ |
136 | 106 | static from(array: Uint8Array): Signature; |
137 | 107 |
|
138 | | - /** |
139 | | - * Constructs a new Signature object. |
140 | | - * @param {Uint8Array} opaque - The raw opaque signature data. |
141 | | - */ |
142 | 108 | constructor(opaque: Uint8Array); |
| 109 | + |
| 110 | + opaque: Uint8Array; |
143 | 111 | } |
144 | 112 |
|
145 | 113 | /** |
146 | | - * Generates a signature from the provided handshake messages and an RSA private key. |
147 | | - * |
148 | | - * @param clientHelloMsg - The ClientHello message as a Uint8Array. |
149 | | - * @param serverHelloMsg - The ServerHello message as a Uint8Array. |
150 | | - * @param encryptedExtensionsMsg - The EncryptedExtensions message as a Uint8Array. |
151 | | - * @param certificateMsg - The Certificate message as a Uint8Array. |
152 | | - * @param RSAprivateKey - The RSA private key used for signing. |
153 | | - * @param sha - The hash algorithm to use (256, 384, or 512). Defaults to 256. |
154 | | - * @returns A promise that resolves to a Uint8Array containing the signature. The resulting object also includes the `transcriptHash` property. |
| 114 | + * Generates a signature for the CertificateVerify message. |
155 | 115 | */ |
156 | 116 | export declare function signatureFrom( |
157 | 117 | clientHelloMsg: Uint8Array, |
158 | 118 | serverHelloMsg: Uint8Array, |
159 | 119 | encryptedExtensionsMsg: Uint8Array, |
160 | 120 | certificateMsg: Uint8Array, |
161 | 121 | RSAprivateKey: CryptoKey, |
162 | | - sha?: 256 | 384 | 512 |
| 122 | + sha?: number, |
163 | 123 | ): Promise<Uint8Array>; |
164 | 124 |
|
165 | 125 | /** |
166 | | - * Computes the Finished message verify_data using the provided finished key and handshake messages. |
167 | | - * |
168 | | - * @param finishedKey - The finished key as a Uint8Array. |
169 | | - * @param sha - The hash algorithm to use (256 or 384). Defaults to 256. |
170 | | - * @param messages - A variable number of handshake messages to include in the transcript hash. |
171 | | - * @returns A promise that resolves to a Finished instance containing the verify_data. The resulting object also includes the `transcriptHash` property. |
| 126 | + * Generates a Finished message. |
172 | 127 | */ |
173 | 128 | export declare function finished( |
174 | 129 | finishedKey: Uint8Array, |
175 | | - sha?: 256 | 384, |
| 130 | + sha: number, |
176 | 131 | ...messages: Uint8Array[] |
177 | 132 | ): Promise<Finished>; |
178 | 133 |
|
179 | | - |
180 | 134 | /** |
181 | | - * Represents the output of the `finished` function. |
| 135 | + * Represents a Finished handshake message. |
182 | 136 | */ |
183 | | -export declare class Finished { |
| 137 | +export declare class Finished extends Uint8Array { |
184 | 138 | /** |
185 | | - * Constructs a Finished instance. |
186 | | - * @param verifyData - The computed verify data. |
| 139 | + * Creates a Finished instance from a message. |
| 140 | + * @param message The input message. |
187 | 141 | */ |
188 | | - constructor(verifyData: ArrayBuffer); |
| 142 | + static fromMsg(message: Uint8Array): Finished; |
189 | 143 |
|
190 | | - /** |
191 | | - * The computed verify data. |
192 | | - */ |
193 | | - verifyData: ArrayBuffer; |
| 144 | + constructor(verify_data: Uint8Array); |
194 | 145 |
|
195 | | - /** |
196 | | - * The hash of the handshake transcript. |
197 | | - */ |
198 | | - transcriptHash: ArrayBuffer; |
| 146 | + verify_data: Uint8Array; |
199 | 147 | } |
0 commit comments