Line data Source code
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 :
10 : #include "ScopedNSSTypes.h"
11 : #include "keythi.h"
12 : #include "nsCOMPtr.h"
13 : #include "nsError.h"
14 : #include "nsIFormProcessor.h"
15 : #include "nsIInterfaceRequestor.h"
16 : #include "nsNSSShutDown.h"
17 : #include "nsString.h"
18 : #include "nsTArray.h"
19 : #include "secmodt.h"
20 :
21 : nsresult GetSlotWithMechanism(uint32_t mechanism,
22 : nsIInterfaceRequestor* ctx,
23 : PK11SlotInfo** retSlot,
24 : nsNSSShutDownPreventionLock& /*proofOfLock*/);
25 :
26 : #define DEFAULT_RSA_KEYGEN_PE 65537L
27 : #define DEFAULT_RSA_KEYGEN_ALG SEC_OID_PKCS1_MD5_WITH_RSA_ENCRYPTION
28 :
29 : mozilla::UniqueSECItem DecodeECParams(const char* curve);
30 :
31 : class nsKeygenFormProcessor : public nsIFormProcessor
32 : , public nsNSSShutDownObject
33 : {
34 : public:
35 : nsKeygenFormProcessor();
36 : nsresult Init();
37 :
38 : virtual nsresult ProcessValue(nsIDOMHTMLElement* aElement,
39 : const nsAString& aName,
40 : nsAString& aValue) override;
41 :
42 : virtual nsresult ProcessValueIPC(const nsAString& aOldValue,
43 : const nsAString& aChallenge,
44 : const nsAString& aKeyType,
45 : const nsAString& aKeyParams,
46 : nsAString& aNewValue) override;
47 :
48 : virtual nsresult ProvideContent(const nsAString& aFormType,
49 : nsTArray<nsString>& aContent,
50 : nsAString& aAttribute) override;
51 : NS_DECL_THREADSAFE_ISUPPORTS
52 :
53 : static nsresult Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
54 :
55 : static void ExtractParams(nsIDOMHTMLElement* aElement,
56 : nsAString& challengeValue,
57 : nsAString& keyTypeValue,
58 : nsAString& keyParamsValue);
59 :
60 : // Nothing to release.
61 0 : virtual void virtualDestroyNSSReference() override {}
62 :
63 : protected:
64 : virtual ~nsKeygenFormProcessor();
65 :
66 : nsresult GetPublicKey(const nsAString& aValue, const nsAString& aChallenge,
67 : const nsString& akeyType, nsAString& aOutPublicKey,
68 : const nsAString& aPqg);
69 : nsresult GetSlot(uint32_t aMechanism, PK11SlotInfo** aSlot);
70 : private:
71 : nsCOMPtr<nsIInterfaceRequestor> m_ctx;
72 :
73 0 : typedef struct SECKeySizeChoiceInfoStr {
74 : nsString name;
75 : int size;
76 : } SECKeySizeChoiceInfo;
77 :
78 : enum { number_of_key_size_choices = 2 };
79 :
80 : SECKeySizeChoiceInfo mSECKeySizeChoiceList[number_of_key_size_choices];
81 : };
82 :
83 : #endif // nsKeygenHandler_h
|