/work/obj-fuzz/dist/include/mozilla/dom/CryptoBuffer.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef mozilla_dom_CryptoBuffer_h |
8 | | #define mozilla_dom_CryptoBuffer_h |
9 | | |
10 | | #include "nsTArray.h" |
11 | | #include "seccomon.h" |
12 | | #include "mozilla/dom/TypedArray.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | class ArrayBufferViewOrArrayBuffer; |
18 | | class OwningArrayBufferViewOrArrayBuffer; |
19 | | |
20 | | class CryptoBuffer : public FallibleTArray<uint8_t> |
21 | | { |
22 | | public: |
23 | | uint8_t* Assign(const CryptoBuffer& aData); |
24 | | uint8_t* Assign(const uint8_t* aData, uint32_t aLength); |
25 | | uint8_t* Assign(const nsACString& aString); |
26 | | uint8_t* Assign(const SECItem* aItem); |
27 | | uint8_t* Assign(const InfallibleTArray<uint8_t>& aData); |
28 | | uint8_t* Assign(const ArrayBuffer& aData); |
29 | | uint8_t* Assign(const ArrayBufferView& aData); |
30 | | uint8_t* Assign(const ArrayBufferViewOrArrayBuffer& aData); |
31 | | uint8_t* Assign(const OwningArrayBufferViewOrArrayBuffer& aData); |
32 | | |
33 | | uint8_t* AppendSECItem(const SECItem* aItem); |
34 | | uint8_t* AppendSECItem(const SECItem& aItem); |
35 | | |
36 | | template<typename T, |
37 | | JSObject* UnwrapArray(JSObject*), |
38 | | void GetLengthAndDataAndSharedness(JSObject*, uint32_t*, bool*, T**)> |
39 | | uint8_t* Assign(const TypedArray_base<T, UnwrapArray, |
40 | | GetLengthAndDataAndSharedness>& aArray) |
41 | 0 | { |
42 | 0 | aArray.ComputeLengthAndData(); |
43 | 0 | return Assign(aArray.Data(), aArray.Length()); |
44 | 0 | } |
45 | | |
46 | | nsresult FromJwkBase64(const nsString& aBase64); |
47 | | nsresult ToJwkBase64(nsString& aBase64) const; |
48 | | bool ToSECItem(PLArenaPool* aArena, SECItem* aItem) const; |
49 | | JSObject* ToUint8Array(JSContext* aCx) const; |
50 | | JSObject* ToArrayBuffer(JSContext* aCx) const; |
51 | | bool ToNewUnsignedBuffer(uint8_t** aBuf, uint32_t* aBufLen) const; |
52 | | |
53 | | bool GetBigIntValue(unsigned long& aRetVal); |
54 | | }; |
55 | | |
56 | | } // namespace dom |
57 | | } // namespace mozilla |
58 | | |
59 | | #endif // mozilla_dom_CryptoBuffer_h |