-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCryptoModule.yml
387 lines (324 loc) · 17.1 KB
/
CryptoModule.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
---
name: Modules.Crypto
summary: Add-on Crypto module
description: |
This module provides access to various encryption and decryption algorithms, and string encodings.
## Getting Started
View the [Using Titanium Modules](https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_How-tos/Using_Modules/) document for instructions on getting
started with using this module in your application. You can download the module from https://github.com/tidev/ti.crypto/releases
## Accessing the crypto Module
To access this module from JavaScript, you would do the following:
``` javascript
var crypto = require("ti.crypto");
```
The `crypto` variable is a reference to the Module object.
extends: Titanium.Module
since: { android: "4.0.0", iphone: "4.0.0", ipad: "4.0.0" }
platforms: [android, iphone, ipad]
excludes:
methods: [addEventListener, fireEvent, removeEventListener]
properties: [bubbleParent]
properties:
- name: STATUS_SUCCESS
summary: |
Used in the [reset](Modules.Crypto.Cryptor.reset) and [release](Modules.Crypto.Cryptor.release) methods
to report success for the operation.
type: Number
permission: read-only
- name: STATUS_ERROR
summary: |
Used in the [Cryptor](Modules.Crypto.Cryptor) methods to report a generic error for an operation.
type: Number
permission: read-only
- name: STATUS_PARAMERROR
summary: |
Used in the [encodeData](Modules.Crypto.encodeData) and [Cryptor](Modules.Crypto.Cryptor) methods to report an error
with the supplied parameters or properties.
type: Number
permission: read-only
- name: STATUS_BUFFERTOOSMALL
summary: |
Used in the [encodeData](Modules.Crypto.encodeData) and [Cryptor](Modules.Crypto.Cryptor) methods to report an error
when the buffer is not long enough to contain the result.
type: Number
permission: read-only
- name: STATUS_MEMORYFAILURE
summary: |
Used in the [encodeData](Modules.Crypto.encodeData) and [Cryptor](Modules.Crypto.Cryptor) methods to report an error
with allocating memory.
Only reported by iOS (though the constant is still defined on Android).
type: Number
permission: read-only
- name: STATUS_ALIGNMENTERROR
summary: |
Used in the [encodeData](Modules.Crypto.encodeData) and [Cryptor](Modules.Crypto.Cryptor) methods to report an error.
This means that the data you are passing is not correctly padded (specifically that the entire data length including padding is
not a multiple of the block size). The most likely cause is that you are truncating your encrypted data somewhere, possibly
outside of this routine.
Only reported by iOS (though the constant is still defined on Android).
type: Number
permission: read-only
- name: STATUS_DECODEERROR
summary: |
Used in the [encodeData](Modules.Crypto.encodeData) and [Cryptor](Modules.Crypto.Cryptor) methods to report an error.
Input data did not decode or decrypt properly.
Only reported by iOS (though the constant is still defined on Android).
type: Number
permission: read-only
- name: STATUS_UNIMPLEMENTED
summary: |
Used in the [getOutputLength](Modules.Crypto.Cryptor.getOutputLength) and various [Cryptor](Modules.Crypto.Cryptor) methods to report an error.
Typically used to indicate the given algorithm/mode is not implemented in this OS version.
Android will report this status only on [getOutputLength](Modules.Crypto.Cryptor.getOutputLength).
Otherwise this status is only reported by iOS for the methods performing operations.
type: Number
permission: read-only
- name: ENCRYPT
summary: |
Set on the [operation](Modules.Crypto.Cryptor.operation) property.
Used in the [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the operation should be to encrypt data.
type: Number
permission: read-only
- name: DECRYPT
summary: |
Set on the [operation](Modules.Crypto.Cryptor.operation) property.
Used in the [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the operation should be to decrypt data.
type: Number
permission: read-only
- name: ALGORITHM_AES128
summary: |
Set on the [algorithm](Modules.Crypto.Cryptor.algorithm) property.
Used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the algorithm used.
See [Advanced_Encryption_Standard](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) for more details.
type: Number
permission: read-only
- name: ALGORITHM_DES
summary: |
Set on the [algorithm](Modules.Crypto.Cryptor.algorithm) property.
Used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the algorithm used.
See [Data_Encryption_Standard](https://en.wikipedia.org/wiki/Data_Encryption_Standard) for more details.
type: Number
permission: read-only
- name: ALGORITHM_3DES
summary: |
Set on the [algorithm](Modules.Crypto.Cryptor.algorithm) property.
Used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the algorithm used.
See [Triple_DES](https://en.wikipedia.org/wiki/Triple_DES) for more details.
type: Number
permission: read-only
- name: ALGORITHM_CAST
summary: |
Set on the [algorithm](Modules.Crypto.Cryptor.algorithm) property.
Used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the algorithm used.
See [CAST-128](https://en.wikipedia.org/wiki/CAST-128) for more details.
type: Number
permission: read-only
- name: ALGORITHM_RC4
summary: |
Set on the [algorithm](Modules.Crypto.Cryptor.algorithm) property.
Used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the algorithm used.
See [RC4](https://en.wikipedia.org/wiki/RC4) for more details.
Note that while defined on Android, this algorithm is unimplemented.
type: Number
permission: read-only
- name: ALGORITHM_RC2
summary: |
Set on the [algorithm](Modules.Crypto.Cryptor.algorithm) property.
Used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the algorithm used.
See [RC2](https://en.wikipedia.org/wiki/RC2) for more details.
type: Number
permission: read-only
- name: OPTION_PKCS7PADDING
summary: |
Set on the [options](Modules.Crypto.Cryptor.options) property.
Used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the algorithm used.
See [Wikipedia](https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS#5_and_PKCS#7) for more details.
type: Number
permission: read-only
- name: OPTION_ECBMODE
summary: |
Set on the [options](Modules.Crypto.Cryptor.options) property.
Used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods to indicate the algorithm used.
See [Wikipedia](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Electronic_Codebook_(ECB)) for more details.
type: Number
permission: read-only
- name: KEYSIZE_AES128
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 16
- name: KEYSIZE_AES192
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 24
- name: KEYSIZE_AES256
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 32
- name: KEYSIZE_DES
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 8
- name: KEYSIZE_3DES
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 24
- name: KEYSIZE_MINCAST
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 5
- name: KEYSIZE_MAXCAST
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 16
- name: KEYSIZE_MINRC4
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 1
- name: KEYSIZE_MAXRC4
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 512
- name: KEYSIZE_MINRC2
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 1
- name: KEYSIZE_MAXRC2
summary: |
Number of bytes used to hold a key of the given type. Useful for creating instances of <Titanium.Buffer> to generate a key for the [key](Modules.Crypto.Cryptor.key) property
used in the [encrypt](Modules.Crypto.Cryptor.encrypt), [decrypt](Modules.Crypto.Cryptor.decrypt), [update](Modules.Crypto.Cryptor.update) and [finish](Modules.Crypto.Cryptor.finish) methods.
type: Number
permission: read-only
value: 128
- name: BLOCKSIZE_AES128
summary: Number of bytes for blocks of the related algorithm.
type: Number
permission: read-only
value: 16
- name: BLOCKSIZE_DES
summary: Number of bytes for blocks of the related algorithm.
type: Number
permission: read-only
value: 8
- name: BLOCKSIZE_3DES
summary: Number of bytes for blocks of the related algorithm.
type: Number
permission: read-only
value: 8
- name: BLOCKSIZE_CAST
summary: Number of bytes for blocks of the related algorithm.
type: Number
permission: read-only
value: 8
- name: BLOCKSIZE_RC2
summary: Number of bytes for blocks of the related algorithm.
type: Number
permission: read-only
value: 8
- name: TYPE_BLOB
summary: |
Used in the [encodeData](Modules.Crypto.encodeData) method to specify expected input is a Ti.Blob instance.
type: Number
permission: read-only
- name: TYPE_HEXSTRING
summary: |
Used in the [encodeData](Modules.Crypto.encodeData) and [decodeData](Modules.Crypto.decodeData) methods
to specify expected string format. A hexadecimal formatted string. Each byte is represented by 2 hexadecimal numbers.
type: Number
permission: read-only
- name: TYPE_BASE64STRING
summary: |
Used in the [encodeData](Modules.Crypto.encodeData) and [decodeData](Modules.Crypto.decodeData) methods
to specify expected string format. A Base64 encoded string.
type: Number
permission: read-only
methods:
- name: encodeData
summary: Encodes the source into the destination buffer using the specified data type. This is a codec method used for converting data to a destination buffer.
since: "3.1.0"
parameters:
- name: dictionary
summary: a dictionary with keys
type: EncodeDataDict
returns:
type: Number
summary: Returns the position after the encoded data inside the destination.
- name: decodeData
summary: Decodes a source buffer into a string using the specified data type. This is a codec method used for converting data from a source buffer into a displayable string.
parameters:
- name: dictionary
summary: a dictionary with keys
type: DecodeDataDict
returns:
type: String
summary: Returns the decoded string
---
name: EncodeDataDict
summary: Simple object passed to <Modules.Crypto.encodeData> to encode data into a Titanium.Buffer.
properties:
- name: source
summary: The data to encode (see 'type' for supported object types)
type: [String, Titanium.Blob]
optional: false
- name: dest
summary: The Titanium.Buffer to receive the encoded data
type: Titanium.Buffer
optional: false
- name: destPosition
summary: |
The position in dest to set the encoded data (optional, default is 0)
type: Number
default: 0
optional: true
- name: type
summary: |
The data type of the source object:
* [TYPE_BASE64STRING](Modules.Crypto.TYPE_BASE64STRING) - source is a base64 encoded string
* [TYPE_HEXSTRING](Modules.Crypto.TYPE_HEXSTRING) - source is a hexadecimal formatted string
* [TYPE_BLOB](Modules.Crypto.TYPE_BLOB) - source is a Titanium.Blob object
type: String
optional: false
---
name: DecodeDataDict
summary: Simple object passed to <Modules.Crypto.decodeData> to decode data into a Titanium.Buffer.
properties:
- name: source
summary: The Titanium.Buffer to decode
type: Titanium.Buffer
optional: false
- name: type
summary: |
The format of the returned string:
* [TYPE_BASE64STRING](Modules.Crypto.TYPE_BASE64STRING) - source is a base64 encoded string
* [TYPE_HEXSTRING](Modules.Crypto.TYPE_HEXSTRING) - source is a hexadecimal formatted string
type: String
optional: false