-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fba3ca1
commit b622f81
Showing
51 changed files
with
2,033 additions
and
1,226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Unit Include | ||
#include "artwork.h" | ||
|
||
// Qt Includes | ||
#include <QDataStream> | ||
|
||
namespace PxCrypt | ||
{ | ||
/*! @cond */ | ||
|
||
//=============================================================================================================== | ||
// BaseArtwork | ||
//=============================================================================================================== | ||
|
||
|
||
/*! @endcond */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef ARTWORK_H | ||
#define ARTWORK_H | ||
|
||
// Qt Includes | ||
#include <QByteArray> | ||
#include <QString> | ||
|
||
using namespace Qt::Literals::StringLiterals; | ||
|
||
namespace PxCrypt | ||
{ | ||
/*! @cond */ | ||
|
||
class IArtwork | ||
{ | ||
//-Class Variables-------------------------------------------------------------------------------------------------------- | ||
private: | ||
static inline const QByteArray MAGIC_NUM = "PXC"_ba; | ||
|
||
//-Constructor--------------------------------------------------------------------------------------------------------- | ||
protected: | ||
IArtwork() = default; | ||
|
||
//-Class Functions---------------------------------------------------------------------------------------------- | ||
public: | ||
|
||
|
||
//-Instance Functions---------------------------------------------------------------------------------------------- | ||
public: | ||
bool isNull() const; | ||
quint64 size() const; | ||
|
||
}; | ||
|
||
template<quint8 CodecNum> | ||
class Artwork : IArtwork | ||
{ | ||
//-Class Variables---------------------------------------------------------------------------------------------------------- | ||
public: | ||
static constexpr quint8 CODEC_NUMBER = CodecNum; | ||
}; | ||
|
||
/*! @endcond */ | ||
} | ||
|
||
#endif // ARTWORK_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Unit Include | ||
#include "base.h" | ||
|
||
// Qt Includes | ||
#include <QDataStream> | ||
|
||
// Qx Includes | ||
#include <qx/core/qx-integrity.h> | ||
|
||
namespace PxCrypt | ||
{ | ||
/*! @cond */ | ||
|
||
//=============================================================================================================== | ||
// BaseArtwork | ||
//=============================================================================================================== | ||
|
||
|
||
/*! @endcond */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef BASE_H | ||
#define BASE_H | ||
|
||
// Qt Includes | ||
#include <QByteArray> | ||
#include <QString> | ||
|
||
using namespace Qt::Literals::StringLiterals; | ||
|
||
namespace PxCrypt | ||
{ | ||
/*! @cond */ | ||
|
||
class BaseArtwork | ||
{ | ||
//-Class Variables-------------------------------------------------------------------------------------------------------- | ||
private: | ||
static inline const QByteArray MAGIC_NUM = "PXC"_ba; | ||
|
||
//-Constructor--------------------------------------------------------------------------------------------------------- | ||
public: | ||
BaseArtwork(); | ||
|
||
//-Class Functions---------------------------------------------------------------------------------------------- | ||
public: | ||
|
||
|
||
//-Instance Functions---------------------------------------------------------------------------------------------- | ||
public: | ||
bool isNull() const; | ||
quint64 size() const; | ||
|
||
}; | ||
|
||
/*! @endcond */ | ||
} | ||
|
||
#endif // BASE_H |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Unit Include | ||
#include "header.h" | ||
|
||
// Qt Includes | ||
#include <QDataStream> | ||
|
||
// Qx Includes | ||
#include <qx/core/qx-integrity.h> | ||
|
||
namespace PxCrypt | ||
{ | ||
/*! @cond */ | ||
|
||
//=============================================================================================================== | ||
// Header | ||
//=============================================================================================================== | ||
|
||
//-Constructor--------------------------------------------------------------------------------------------------------- | ||
//Public: | ||
Header::Header() : | ||
mChecksum(0), | ||
mPayloadSize(0), | ||
mTag() | ||
{} | ||
|
||
Header::Header(QByteArrayView payload, const QString& tag) : | ||
mChecksum(Qx::Integrity::crc32(payload)), | ||
mPayloadSize(payload.size()), | ||
mTag(tag.toUtf8()) | ||
{ | ||
if(mTag.size() > std::numeric_limits<tag_length_t>::max()) | ||
mTag.resize(std::numeric_limits<tag_length_t>::max()); | ||
} | ||
|
||
//-Class Functions---------------------------------------------------------------------------------------------- | ||
//Public: | ||
quint64 Header::sizeOf(tag_length_t tagLength) | ||
{ | ||
return MAGIC_NUM.size() + | ||
sizeof(mChecksum) + | ||
sizeof(tag_length_t) + | ||
sizeof(mPayloadSize) + | ||
tagLength; | ||
} | ||
|
||
//-Instance Functions-------------------------------------------------------------------------------------------- | ||
//Public: | ||
bool Header::isNull() const { return mChecksum == 0 & mPayloadSize == 0 & mTag.isNull(); } | ||
quint32 Header::checksum() const { return mChecksum; } | ||
QByteArray Header::tag() const { return mTag; }; | ||
quint16 Header::tagSize() const { return mTag.size(); } | ||
quint32 Header::payloadSize() const { return mPayloadSize; } | ||
quint64 Header::size() const { return sizeOf(static_cast<tag_length_t>(mTag.size())); } | ||
|
||
//-Non-member/Related Functions------------------------------------------------------------------------------------ | ||
QDataStream& operator<<(QDataStream& ds, const Header& h) | ||
{ | ||
ds.writeRawData(Header::MAGIC_NUM, Header::MAGIC_NUM.size()); | ||
ds << h.mChecksum | ||
<< static_cast<Header::tag_length_t>(h.mTag.size()) | ||
<< h.mPayloadSize; | ||
ds.writeRawData(h.mTag, h.mTag.size()); | ||
|
||
return ds; | ||
} | ||
|
||
QDataStream& operator>>(QDataStream& ds, Header& h) | ||
{ | ||
h = Header(); | ||
|
||
QByteArray magic(Header::MAGIC_NUM.size(), Qt::Uninitialized); | ||
ds.readRawData(magic.data(), Header::MAGIC_NUM.size()); | ||
if(magic != Header::MAGIC_NUM) | ||
return ds; | ||
|
||
ds >> h.mChecksum; | ||
Header::tag_length_t tl; | ||
ds >> tl; | ||
ds >> h.mPayloadSize; | ||
h.mTag.resize(tl); | ||
ds.readRawData(h.mTag.data(), tl); | ||
|
||
return ds; | ||
} | ||
|
||
/*! @endcond */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#ifndef HEADER_H | ||
#define HEADER_H | ||
|
||
// Qt Includes | ||
#include <QByteArray> | ||
#include <QString> | ||
|
||
using namespace Qt::Literals::StringLiterals; | ||
|
||
namespace PxCrypt | ||
{ | ||
/*! @cond */ | ||
|
||
class Header | ||
{ | ||
//-Class Types------------------------------------------------------------------------------------------------------------ | ||
using tag_length_t = quint16; | ||
|
||
//-Class Variables-------------------------------------------------------------------------------------------------------- | ||
private: | ||
static inline const QByteArray MAGIC_NUM = "PXC"_ba; | ||
|
||
//-Instance Variables------------------------------------------------------------------------------------------------------ | ||
private: | ||
quint32 mChecksum; | ||
quint32 mPayloadSize; | ||
QByteArray mTag; | ||
|
||
//-Constructor--------------------------------------------------------------------------------------------------------- | ||
public: | ||
Header(); | ||
Header(QByteArrayView payload, const QString& tag); | ||
|
||
//-Class Functions---------------------------------------------------------------------------------------------- | ||
public: | ||
static quint64 sizeOf(tag_length_t tagLength = 0); // Zero to see minimum without tag | ||
|
||
//-Instance Functions---------------------------------------------------------------------------------------------- | ||
public: | ||
bool isNull() const; | ||
quint32 checksum() const; | ||
QByteArray tag() const; | ||
quint16 tagSize() const; | ||
quint32 payloadSize() const; | ||
|
||
quint64 size() const; | ||
|
||
//-Friend Functions------------------------------------------------------------------------------------------------ | ||
friend QDataStream& operator<<(QDataStream& ds, const Header& h); | ||
friend QDataStream& operator>>(QDataStream& ds, Header& h); | ||
}; | ||
|
||
//-Non-member/Related Functions------------------------------------------------------------------------------------ | ||
QDataStream& operator<<(QDataStream& ds, const Header& h); | ||
QDataStream& operator>>(QDataStream& ds, Header& h); | ||
|
||
/*! @endcond */ | ||
} | ||
|
||
#endif // HEADER_H |
Oops, something went wrong.