void DigestTransform::AttributeChanged(CFStringRef name, CFTypeRef value) { if (CFStringCompare(name, kSecTransformInputAttributeName, 0) == kCFCompareEqualTo) { if (value == NULL) { // we are done, finalize the digest and send the result forward const void* result = mDigest->Finalize(); // send the result CFDataRef resultRef = CFDataCreate(NULL, (UInt8*) result, mDigest->DigestLength()); SendAttribute(kSecTransformOutputAttributeName, resultRef); CFRelease(resultRef); // send the EOS SendAttribute(kSecTransformOutputAttributeName, NULL); } else { // if we got an error, just pass it on CFTypeID valueType = CFGetTypeID(value); if (valueType == CFErrorGetTypeID()) { SendAttribute(kSecTransformOutputAttributeName, value); } else if (valueType != CFDataGetTypeID()) { CFStringRef idType = CFCopyTypeIDDescription(valueType); CFErrorRef result = CreateSecTransformErrorRef(kSecTransformErrorInvalidType, "value is not a CFDataRef -- it's a %@ instead", idType); CFRelease(idType); SetAttributeNoCallback(kSecTransformOutputAttributeName, result); } else { CFDataRef valueRef = (CFDataRef) value; mDigest->Update(CFDataGetBytePtr(valueRef), CFDataGetLength(valueRef)); } } } }
bool Type::IsError( void ) const { return this->GetTypeID() == CFErrorGetTypeID(); }