139 lines
4.5 KiB
C++
139 lines
4.5 KiB
C++
#pragma once
|
|
/*
|
|
* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
|
|
*
|
|
* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
|
|
* and international copyright treaties.
|
|
*
|
|
* Access to and use of the software is governed by the terms of the applicable OnixS Software
|
|
* Services Agreement (the Agreement) and Customer end user license agreements granting
|
|
* a non-assignable, non-transferable and non-exclusive license to use the software
|
|
* for it's own data processing purposes under the terms defined in the Agreement.
|
|
*
|
|
* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
|
|
* of this source code or associated reference material to any other location for further reproduction
|
|
* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
|
|
*
|
|
* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
|
|
* the terms of the Agreement is a violation of copyright law.
|
|
*/
|
|
|
|
#include <OnixS/FIXEngine/ABI.h>
|
|
|
|
#include <OnixS/FIXEngine/FIX/StringRef.h>
|
|
|
|
namespace OnixS {
|
|
namespace Cryptography {
|
|
|
|
/// The immutable secure string
|
|
class ONIXS_FIXENGINE_API SecureString
|
|
{
|
|
public:
|
|
/// Constructs the empty SecureString.
|
|
SecureString();
|
|
|
|
/// Constructs the SecureString which stores the encrypted plainText.
|
|
///
|
|
/// @param plainText The plain text to be encrypted and stored.
|
|
explicit SecureString(FIX::StringRef plainText);
|
|
|
|
/// Constructs the SecureString which stores the encrypted plainText.
|
|
///
|
|
/// @param plainText The plain text to be encrypted and stored.
|
|
/// @param plainTextLength The plain text length.
|
|
SecureString(const char * plainText, size_t plainTextLength);
|
|
|
|
/// Initializes the instance as a shallow copy of other one.
|
|
SecureString(const SecureString & other);
|
|
|
|
/// Makes a shallow copy of another SecureString.
|
|
SecureString & operator=(const SecureString & other);
|
|
|
|
/// Disposes all internal data structures.
|
|
~SecureString();
|
|
|
|
/// The length of the plain string.
|
|
size_t length() const;
|
|
|
|
/// Indicates whether the SecureString has no data.
|
|
bool empty() const;
|
|
|
|
protected:
|
|
class Impl;
|
|
SecureString(const Impl *);
|
|
|
|
private:
|
|
const Impl * impl_;
|
|
};
|
|
|
|
/// The editable secure string.
|
|
class ONIXS_FIXENGINE_API SecureStringBuilder
|
|
{
|
|
public:
|
|
/// Constructs the empty SecureStringBuilder.
|
|
explicit SecureStringBuilder();
|
|
|
|
/// Constructs the SecureStringBuilder which stores the encrypted plainText as an initial value.
|
|
///
|
|
/// @param plainText The plain text to be encrypted and stored.
|
|
explicit SecureStringBuilder(FIX::StringRef plainText);
|
|
|
|
/// Constructs the SecureStringBuilder which stores the encrypted plainText as an initial value.
|
|
///
|
|
/// @param plainText The plain text to be encrypted and stored.
|
|
/// @param plainTextLength The plain text length.
|
|
SecureStringBuilder(const char * plainText, size_t plainTextLength);
|
|
|
|
/// Initializes the instance as a deep copy of other one.
|
|
SecureStringBuilder(const SecureStringBuilder & other);
|
|
|
|
/// Makes a deep copy of another SecureStringBuilder.
|
|
SecureStringBuilder & operator=(const SecureStringBuilder & other);
|
|
|
|
~SecureStringBuilder();
|
|
|
|
/// Gets the number of characters in the current secure string.
|
|
size_t length() const;
|
|
|
|
/// Moves the encoded data to the immutable SecureString object.
|
|
///
|
|
/// SecureStringBuilder becomes empty after detaching.
|
|
SecureString detach();
|
|
|
|
/// Replaces the secure value with a new one.
|
|
///
|
|
/// @param plainText plain text to be encrypted and stored.
|
|
void assign(FIX::StringRef plainText);
|
|
|
|
/// Replaces internal value with a new one.
|
|
///
|
|
/// @param plainText The plain text to be encrypted and stored.
|
|
/// @param plainTextLength The plain text length.
|
|
void assign(const char * plainText, size_t plainTextLength);
|
|
|
|
/// Appends a character to the end of the current secure string.
|
|
void append(char c);
|
|
|
|
/// Inserts a character in this secure string at the specified index position.
|
|
void insert(size_t index, char c);
|
|
|
|
/// Replaces the existing character at the specified index position with another character.
|
|
void replace(size_t index, char c);
|
|
|
|
/// Removes the character at the specified index position from this secure string.
|
|
void erase(size_t index);
|
|
|
|
/// Deletes the value of the current secure string.
|
|
void clear();
|
|
|
|
protected:
|
|
class Impl;
|
|
|
|
private:
|
|
Impl * impl_;
|
|
};
|
|
|
|
|
|
}
|
|
}
|