MCPcopy Create free account
hub / github.com/apache/brpc / copy_shared_key

Method copy_shared_key

src/brpc/policy/dh.cpp:75–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75int DHWrapper::copy_shared_key(const void* ppkey, int ppkey_size,
76 void* skey, int* skey_size) const {
77 BIGNUM* ppk = BN_bin2bn((const unsigned char*)ppkey, ppkey_size, 0);
78 if (ppk == NULL) {
79 LOG(ERROR) << "Fail to BN_bin2bn";
80 return -1;
81 }
82 // @see https://github.com/ossrs/srs/issues/165
83 int key_size = DH_compute_key((unsigned char*)skey, ppk, _pdh);
84 if (key_size < 0 || key_size > *skey_size) {
85 LOG(ERROR) << "Fail to compute shared key";
86 BN_free(ppk);
87 return -1;
88 }
89 *skey_size = key_size;
90 return 0;
91}
92
93int DHWrapper::do_initialize() {
94 BIGNUM* p = get_rfc2409_prime_1024(NULL);

Callers 1

GenerateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected