Merge pull request #4072 from B3n30/httpc3

Service::HTTP_C: Implement Client Cert opening and closing
This commit is contained in:
Weiyi Wang
2018-09-29 22:53:49 -04:00
committed by GitHub
2 changed files with 203 additions and 3 deletions

View File

@@ -42,6 +42,8 @@ enum class RequestState : u8 {
struct ClientCertContext {
using Handle = u32;
Handle handle;
u32 session_id;
u8 cert_id;
std::vector<u8> certificate;
std::vector<u8> private_key;
};
@@ -53,11 +55,13 @@ struct RootCertChain {
struct RootCACert {
using Handle = u32;
Handle handle;
u32 session_id;
std::vector<u8> certificate;
};
using Handle = u32;
Handle handle;
u32 session_id;
std::vector<RootCACert> certificates;
};
@@ -104,6 +108,7 @@ public:
};
Handle handle;
u32 session_id;
std::string url;
RequestMethod method;
RequestState state = RequestState::NotStarted;
@@ -120,6 +125,8 @@ struct SessionData : public Kernel::SessionRequestHandler::SessionDataBase {
/// has been bound. Certain commands can only be called on a session with a bound context.
boost::optional<Context::Handle> current_http_context;
u32 session_id;
/// Number of HTTP contexts that are currently opened in this session.
u32 num_http_contexts = 0;
/// Number of ClientCert contexts that are currently opened in this session.
@@ -196,10 +203,46 @@ private:
*/
void AddRequestHeader(Kernel::HLERequestContext& ctx);
/**
* HTTP_C::OpenClientCertContext service function
* Inputs:
* 1 : Cert size
* 2 : Key size
* 3 : (CertSize<<4) | 10
* 4 : Pointer to input cert
* 5 : (KeySize<<4) | 10
* 6 : Pointer to input key
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void OpenClientCertContext(Kernel::HLERequestContext& ctx);
/**
* HTTP_C::OpenDefaultClientCertContext service function
* Inputs:
* 1 : CertID
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
* 2 : Client Cert context handle
*/
void OpenDefaultClientCertContext(Kernel::HLERequestContext& ctx);
/**
* HTTP_C::CloseClientCertContext service function
* Inputs:
* 1 : ClientCert Handle
* Outputs:
* 1 : Result of function, 0 on success, otherwise error code
*/
void CloseClientCertContext(Kernel::HLERequestContext& ctx);
void DecryptClCertA();
Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr;
/// The next number to use when a new HTTP session is initalized.
u32 session_counter = 0;
/// The next handle number to use when a new HTTP context is created.
Context::Handle context_counter = 0;