Example #1
0
  QByteArray NullPrivateKey::Decrypt(const QByteArray &data) const
  {
    if(data.size() < (GetKeySize() / 8) || !_valid) {
      return QByteArray();
    }

    uint key_id = Dissent::Utils::Serialization::ReadInt(data, 0);
    if(key_id != _key_id) {
      return QByteArray();
    }
    return data.mid((GetKeySize() / 8));
  }
OP_STATUS CryptoStreamEncryptionCBC::SetKey(const UINT8 *key)
{
	OP_ASSERT(key);

	if (!key)
		return OpStatus::ERR;

	op_memmove(m_key, key, GetKeySize());
	return OpStatus::OK;
}
Example #3
0
  bool NullPublicKey::Verify(const QByteArray &data, const QByteArray &sig) const
  {
    if(sig.size() != (GetKeySize() / 8) || !_valid) {
      return false;
    }

    uint key_id = Dissent::Utils::Serialization::ReadInt(sig, 0);
    uint hash = Dissent::Utils::Serialization::ReadInt(sig, 4);
    return hash == qHash(data) && key_id == _key_id;
  }
Example #4
0
	void Cipher::SetKey (const ConstBufferPtr &key)
	{
		if (key.Size() != GetKeySize ())
			throw ParameterIncorrect (SRC_POS);

		if (!Initialized)
			ScheduledKey.Allocate (GetScheduledKeySize ());

		SetCipherKey (key);
		Key.CopyFrom (key);
		Initialized = true;
	}
	void EncryptionAlgorithm::SetKey (const ConstBufferPtr &key)
	{
		if (Ciphers.size() < 1)
			throw NotInitialized (SRC_POS);

		if (GetKeySize() != key.Size())
			throw ParameterIncorrect (SRC_POS);

		size_t keyOffset = 0;
		foreach_ref (Cipher &c, Ciphers)
		{
			c.SetKey (key.GetRange (keyOffset, c.GetKeySize()));
			keyOffset += c.GetKeySize();
		}
static OSStatus MakeKeyGenParametersFromDictionary(CFDictionaryRef parameters,
												   CSSM_ALGORITHMS &algorithms,
												   uint32 &keySizeInBits,
												   CSSM_KEYUSE &publicKeyUse,
												   uint32 &publicKeyAttr,
												   CFTypeRef &publicKeyLabelRef,
												   CFDataRef &publicKeyAttributeTagRef,
												   CSSM_KEYUSE &privateKeyUse,
												   uint32 &privateKeyAttr,
												   CFTypeRef &privateKeyLabelRef,
												   CFDataRef &privateKeyAttributeTagRef,
												   SecAccessRef &initialAccess)
{
	OSStatus result;
	
	result = CheckAlgorithmType(parameters, algorithms);
	if (result != noErr)
	{
		return result;
	}
	
	result = GetKeySize(parameters, algorithms, keySizeInBits);
	if (result != noErr)
	{
		return result;
	}

	result = GetKeyParameters(parameters, keySizeInBits, false, privateKeyUse, privateKeyAttr, publicKeyLabelRef, publicKeyAttributeTagRef);
	if (result != noErr)
	{
		return result;
	}
	
	result = GetKeyParameters(parameters, keySizeInBits, true, publicKeyUse, publicKeyAttr, privateKeyLabelRef, privateKeyAttributeTagRef);
	if (result != noErr)
	{
		return result;
	}
	
	if (!CFDictionaryGetValueIfPresent(parameters, kSecAttrAccess, (const void **)&initialAccess))
	{
		initialAccess = NULL;
	}
	else if (SecAccessGetTypeID() != CFGetTypeID(initialAccess))
	{
		return paramErr;
	}
	
	return noErr;
}
Example #7
0
  bool NullPublicKey::InitFromByteArray(const QByteArray &data)
  {
    if(data.size() != (GetKeySize() / 8)) {
      return false;
    }

    int pu_pr = Dissent::Utils::Serialization::ReadInt(data, 0);
    if(pu_pr == 0) {
      _private = false;
    } else if(pu_pr == 1) {
      _private = true;
    } else {
      return false;
    }

    _key_id = Dissent::Utils::Serialization::ReadInt(data, 4);
    return true;
  }
Example #8
0
 int CppRsaPublicKeyImpl::GetSignatureLength() const
 {
   return GetKeySize() / 8;
 }
Example #9
0
 /**
  * Returns the signature size in bytes
  */
 virtual int GetSignatureLength() const
 {
   ///@todo this is a temporary hack as each implementation should be fixed
   return GetKeySize() / 8;
 }