MCPcopy Create free account
hub / github.com/SmingHub/Sming / decode

Method decode

Sming/Components/ssl/BearSsl/BrPublicKey.cpp:19–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17namespace Ssl
18{
19bool BrPublicKey::decode(const uint8_t* buf, size_t len)
20{
21 freeMem();
22
23 br_pkey_decoder_context dc;
24 br_pkey_decoder_init(&dc);
25 br_pkey_decoder_push(&dc, buf, len);
26 int err = br_pkey_decoder_last_error(&dc);
27 if(err != 0) {
28 return false;
29 }
30
31 int type = br_pkey_decoder_key_type(&dc);
32 switch(type) {
33 case BR_KEYTYPE_RSA:
34 return copy(*br_pkey_decoder_get_rsa(&dc));
35
36 case BR_KEYTYPE_EC:
37 return copy(*br_pkey_decoder_get_ec(&dc));
38
39 default:
40 debug_e("[SSL] Unknown key type: %d", type);
41 return false;
42 }
43}
44
45bool BrPublicKey::copy(const br_rsa_public_key& rsa)
46{

Callers 1

initMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected