summaryrefslogtreecommitdiff
path: root/utils/mir_signal.cpp
blob: d4e03e6803e78da4da4083ad2720f424796f2e12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <Windows.h>

#include <m_string.h>

#include "mir_signal.h"

SignalBuffer::SignalBuffer(const MBinBuffer &buf)
{
	m_buf = signal_buffer_create(buf.data(), buf.length());
}

SignalBuffer::SignalBuffer(const ec_public_key *key)
{
	ec_public_key_serialize(&m_buf, key);
}

SignalBuffer::SignalBuffer(const ec_private_key *key)
{
	ec_private_key_serialize(&m_buf, key);
}

SignalBuffer::SignalBuffer(const session_pre_key *pre_key)
{
	session_pre_key_serialize(&m_buf, pre_key);
}

SignalBuffer::SignalBuffer(const session_signed_pre_key *pre_key)
{
	session_signed_pre_key_serialize(&m_buf, pre_key);
}

SignalBuffer::~SignalBuffer()
{
	signal_buffer_free(m_buf);
}

CMStringA SignalBuffer::toBase64() const
{
	return ptrA(mir_base64_encode(m_buf->data, m_buf->len)).get();
}

void SignalBuffer::operator=(signal_buffer *buf)
{
	if (m_buf)
		signal_buffer_free(m_buf);

	m_buf = buf;
}