Exemplo n.º 1
0
Identifier::Identifier(
    const proto::ContactItemType type,
    const proto::HDPath& path)
    : ot_super()
{
    CalculateDigest(path_to_data(type, path), DefaultType);
}
// static
std::string VerificationCredential::VerificationID(
    const proto::Verification& item)
{
    auto id = Identifier::Factory();
    id->CalculateDigest(proto::ProtoAsData<proto::Verification>(item));

    return String::Factory(id)->Get();
}
Exemplo n.º 3
0
bool OTIdentifier::CalculateDigestInternal(const OTData & dataInput, const OTString & strHashAlgorithm)
{
	// See if they wanted to use the SAMY hash
	if (strHashAlgorithm.Compare(DefaultHashAlgorithm)) 
	{
		return CalculateDigest(dataInput);
	}
	
	return false;	
}
Exemplo n.º 4
0
OTIdentifier Context::GetID(const Lock& lock) const
{
    OT_ASSERT(verify_write_lock(lock));

    auto contract = IDVersion(lock);
    auto id = Identifier::Factory();
    id->CalculateDigest(proto::ProtoAsData(contract));

    return id;
}
Exemplo n.º 5
0
Identifier* Identifier::contract_contents_to_identifier(const Contract& in)
{
    auto output = new Identifier();

    OT_ASSERT(nullptr != output);

    output->CalculateDigest(String::Factory(in));

    return output;
}
Exemplo n.º 6
0
// This method implements the SAMY hash
bool OTIdentifier::CalculateDigest(const OTData & dataInput)
{
#ifndef ANDROID // SHA256 on Android; no whirlpool until OpenSSL 1.0.0 is added.
	OTIdentifier idSecondHash;
	
	if (idSecondHash.CalculateDigest(dataInput, HashAlgorithm2) &&
		CalculateDigest(dataInput, HashAlgorithm1))
	{
		// At this point, we have successfully generated the WHRLPOOL hash in 
		// idSecondHash, and we've successfully generated the SHA-256 hash in 
		// this object.
		// Next we XOR them together for the final product.
		return XOR(idSecondHash);
	}
#else // ANDROID
	if (CalculateDigest(dataInput, HashAlgorithm1)) // SHA256 only until I add the new OpenSSL 1.0 for Android
	{
		return true;
	}	
#endif // ANDROID
	
	return false;
}
Exemplo n.º 7
0
OTIdentifier PeerRequest::GetID(const proto::PeerRequest& contract)
{
    auto id = Identifier::Factory();
    id->CalculateDigest(proto::ProtoAsData(contract));
    return id;
}
Exemplo n.º 8
0
bool Identifier::CalculateDigest(const OTData& dataInput)
{
    auto dataPtr = static_cast<const unsigned char*>(dataInput.GetPointer());
    return CalculateDigest(dataPtr, dataInput.GetSize());
}
Exemplo n.º 9
0
bool Identifier::CalculateDigest(const String& strInput)
{
    return CalculateDigest(
        reinterpret_cast<const unsigned char*>(strInput.Get()),
        static_cast<size_t>(strInput.GetLength()));
}