File: BioByteArray.h

package info (click to toggle)
xca 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,328 kB
  • sloc: cpp: 30,584; sh: 341; xml: 74; makefile: 56; python: 34
file content (47 lines) | stat: -rw-r--r-- 1,097 bytes parent folder | download | duplicates (2)
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
/* vi: set sw=4 ts=4:
 *
 * Copyright (C) 2020 Christian Hohnstaedt.
 *
 * All rights reserved.
 */

#ifndef __BIOBYTEARRAY_H
#define __BIOBYTEARRAY_H

#include <QByteArray>
#include <QString>
#include <openssl/bio.h>
#include <openssl/bn.h>

class BioByteArray
{
  protected:
	BIO *read_write{};
	BIO *read_only{};
	QByteArray store{};

	void set(const QByteArray &qba);
	void add(const QByteArray &qba);
	void biowrite(const QByteArray &qba);
	void cleanse_and_free(BIO *bio);

  public:
	BioByteArray(const QByteArray &qba) : store(qba) { }
	BioByteArray(const BioByteArray &bba) : store(bba.byteArray()) { }
	BioByteArray(const BIGNUM *bn, int len = 0);
	BioByteArray() { }
	~BioByteArray();
	int size() const;
	BIO *bio();
	BIO *ro();
	QByteArray byteArray() const;
	QString qstring() const;
	QString base64UrlEncode() const;
	operator BIO*();
	operator QByteArray();
	BioByteArray &operator = (const BioByteArray &other);
	BioByteArray &operator = (const QByteArray &qba);
	BioByteArray &operator += (const BioByteArray &other);
	BioByteArray &operator += (const QByteArray &qba);
};
#endif