|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * |
|
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 _NSKEYGENHANDLER_H_ |
|
8 #define _NSKEYGENHANDLER_H_ |
|
9 // Form Processor |
|
10 #include "nsIFormProcessor.h" |
|
11 #include "nsTArray.h" |
|
12 |
|
13 nsresult GetSlotWithMechanism(uint32_t mechanism, |
|
14 nsIInterfaceRequestor *ctx, |
|
15 PK11SlotInfo **retSlot); |
|
16 |
|
17 #define DEFAULT_RSA_KEYGEN_PE 65537L |
|
18 #define DEFAULT_RSA_KEYGEN_ALG SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION |
|
19 |
|
20 SECKEYECParams *decode_ec_params(const char *curve); |
|
21 |
|
22 class nsKeygenFormProcessor : public nsIFormProcessor { |
|
23 public: |
|
24 nsKeygenFormProcessor(); |
|
25 virtual ~nsKeygenFormProcessor(); |
|
26 nsresult Init(); |
|
27 |
|
28 NS_IMETHOD ProcessValue(nsIDOMHTMLElement *aElement, |
|
29 const nsAString& aName, |
|
30 nsAString& aValue); |
|
31 |
|
32 NS_IMETHOD ProvideContent(const nsAString& aFormType, |
|
33 nsTArray<nsString>& aContent, |
|
34 nsAString& aAttribute); |
|
35 NS_DECL_THREADSAFE_ISUPPORTS |
|
36 |
|
37 static nsresult Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); |
|
38 |
|
39 protected: |
|
40 nsresult GetPublicKey(nsAString& aValue, nsAString& aChallenge, |
|
41 nsAFlatString& akeyType, nsAString& aOutPublicKey, |
|
42 nsAString& aPqg); |
|
43 nsresult GetSlot(uint32_t aMechanism, PK11SlotInfo** aSlot); |
|
44 private: |
|
45 nsCOMPtr<nsIInterfaceRequestor> m_ctx; |
|
46 |
|
47 typedef struct SECKeySizeChoiceInfoStr { |
|
48 nsString name; |
|
49 int size; |
|
50 } SECKeySizeChoiceInfo; |
|
51 |
|
52 enum { number_of_key_size_choices = 2 }; |
|
53 |
|
54 SECKeySizeChoiceInfo mSECKeySizeChoiceList[number_of_key_size_choices]; |
|
55 }; |
|
56 |
|
57 #endif //_NSKEYGENHANDLER_H_ |