VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/Hash.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-08-17Linux/MacOSX: Add Streebog to the list of supported hash algorithms used for ↵Mounir IDRASSI1-0/+1
key derivation.
2016-08-17Linux: fix various compilation issues under Linux.Mounir IDRASSI1-1/+1
2016-08-15Windows: Add support for Streebog (hash) and kuznyechik (encryption)Mounir IDRASSI1-0/+25
2016-07-25Windows: solve benchmark issue for Whirlpool which caused wrong numbers when ↵Mounir IDRASSI1-1/+1
a 1GB buffer is chosen.
2016-05-10Remove trailing whitespaceDavid Foerster1-3/+3
2016-01-20Copyright: update dates to include 2016.Mounir IDRASSI1-1/+1
2015-08-06Update license information to reflect the use of a dual license Apache 2.0 ↵Mounir IDRASSI1-5/+9
and TrueCrypt 3.0.
2015-02-08Linux/MacOSX: mark RIPEMD-160 as deprecated like it's the case on Windows. ↵Mounir IDRASSI1-0/+1
It will no more be available for the creation of volumes.
2014-11-08Integrate SHA-256 support into Linux/MacOSX code. Set PRF priority to ↵Mounir IDRASSI1-2/+27
SHA-512 -> Whirlpool -> SHA-256 -> RIPEMD-160 .
2014-11-08Remove remaining legacy cryptographic algorithms that are never used by ↵Mounir IDRASSI1-27/+0
VeraCrypt.
2014-11-08Change namespace from TrueCrypt to VeraCrypt. Rename method from Resources ↵Mounir IDRASSI1-1/+1
Resources::GetTrueCryptIcon to Resources::GetVeraCryptIcon.
2014-11-08Add TrueCrypt 7.1a MacOSX/Linux specific source files.Mounir IDRASSI1-0/+138
imiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.

 Governed by the TrueCrypt License 3.0 the full text of which is contained in
 the file License.txt included in TrueCrypt binary and source code distribution
 packages.
*/

#ifndef TC_HEADER_Platform_SerializerFactory
#define TC_HEADER_Platform_SerializerFactory

#include <typeinfo>
#include "PlatformBase.h"
#include "StringConverter.h"

namespace VeraCrypt
{
	class Serializable;

	class SerializerFactory
	{
	public:
		~SerializerFactory ();

		static void Deinitialize ();
		static string GetName (const type_info &typeInfo);
		static Serializable *GetNewSerializable (const string &typeName);
		static void Initialize ();

		struct MapEntry
		{
			MapEntry () { }
			MapEntry (const string &typeName, Serializable* (*getNewPtr) ())
				: TypeName (typeName), GetNewPtr (getNewPtr) { }

			MapEntry &operator= (const MapEntry &right)
			{
				TypeName = right.TypeName;
				GetNewPtr = right.GetNewPtr;
				return *this;
			}

			string TypeName;
			Serializable* (*GetNewPtr) ();
		};

		static map <string, MapEntry> *NameToTypeMap;
		static map <string, string> *TypeToNameMap;

	protected:
		SerializerFactory ();

		static int UseCount;
	};

}

#define TC_SERIALIZER_FACTORY_ADD_EXCEPTION_SET(TYPE) \
	struct TYPE##SerializerFactoryInitializer \
	{ \
		TYPE##SerializerFactoryInitializer () \
		{ \
			SerializerFactory::Initialize(); \
			TC_EXCEPTION_SET; \
		} \
		~TYPE##SerializerFactoryInitializer () \
		{ \
			SerializerFactory::Deinitialize(); \
		} \
	}; \
	static TYPE##SerializerFactoryInitializer TYPE##SerializerFactoryInitializer

#define TC_SERIALIZER_FACTORY_ADD_CLASS(TYPE) \
	struct TYPE##SerializerFactoryInitializer \
	{ \
		TYPE##SerializerFactoryInitializer () \
		{ \
			SerializerFactory::Initialize(); \
			TC_SERIALIZER_FACTORY_ADD (TYPE); \
		} \
		~TYPE##SerializerFactoryInitializer () \
		{ \
			SerializerFactory::Deinitialize(); \
		} \
	}; \
	static TYPE##SerializerFactoryInitializer TYPE##SerializerFactoryInitializerInst

#define TC_SERIALIZER_FACTORY_ADD(TYPE) \
	(*SerializerFactory::NameToTypeMap)[#TYPE] = SerializerFactory::MapEntry (StringConverter::GetTypeName (typeid (TYPE)), &TYPE::GetNewSerializable); \
	(*SerializerFactory::TypeToNameMap)[StringConverter::GetTypeName (typeid (TYPE))] = #TYPE


#endif // TC_HEADER_Platform_SerializerFactory