JSC::JSValue JSWebGLRenderingContextBase::uniformMatrix2fv(JSC::ExecState& state) { return dataFunctionMatrix(f_uniformMatrix2fv, state, wrapped()); }
bool BotanAES::unwrapKey(const SymmetricKey* key, const SymWrap::Type mode, const ByteString& in, ByteString& out) { // Check key bit length; AES only supports 128, 192 or 256 bit keys if ((key->getBitLen() != 128) && (key->getBitLen() != 192) && (key->getBitLen() != 256)) { ERROR_MSG("Invalid AES key length (%d bits)", key->getBitLen()); return false; } // Determine the unwrapping mode if (mode == SymWrap::AES_KEYWRAP) { // RFC 3394 AES key wrap if (in.size() < 24) { ERROR_MSG("key data to unwrap too small"); return false; } if ((in.size() % 8) != 0) { ERROR_MSG("key data to unwrap not aligned"); return false; } #if BOTAN_VERSION_MINOR == 11 Botan::secure_vector<Botan::byte> wrapped(in.size()); memcpy(wrapped.data(), in.const_byte_str(), in.size()); Botan::secure_vector<Botan::byte> unwrapped; #else Botan::MemoryVector<Botan::byte> wrapped(in.size()); memcpy(wrapped.begin(), in.const_byte_str(), in.size()); Botan::SecureVector<Botan::byte> unwrapped; #endif Botan::SymmetricKey botanKey = Botan::SymmetricKey(key->getKeyBits().const_byte_str(), key->getKeyBits().size()); Botan::Algorithm_Factory& af = Botan::global_state().algorithm_factory(); try { unwrapped = Botan::rfc3394_keyunwrap(wrapped, botanKey, af); } catch (...) { ERROR_MSG("AES key unwrap failed"); return false; } out.resize(unwrapped.size()); #if BOTAN_VERSION_MINOR == 11 memcpy(&out[0], unwrapped.data(), out.size()); #else memcpy(&out[0], unwrapped.begin(), out.size()); #endif return true; } #ifdef HAVE_AES_KEY_WRAP_PAD else if (mode == SymWrap::AES_KEYWRAP_PAD) { // RFC 5649 AES key wrap with wrap if (in.size() < 16) { ERROR_MSG("key data to unwrap too small"); return false; } if ((in.size() % 8) != 0) { ERROR_MSG("key data to unwrap not aligned"); return false; } #if BOTAN_VERSION_MINOR == 11 Botan::secure_vector<Botan::byte> wrapped(in.size()); memcpy(wrapped.data(), in.const_byte_str(), in.size()); Botan::secure_vector<Botan::byte> unwrapped; #else Botan::MemoryVector<Botan::byte> wrapped(in.size()); memcpy(wrapped.begin(), in.const_byte_str(), in.size()); Botan::SecureVector<Botan::byte> unwrapped; #endif Botan::SymmetricKey botanKey = Botan::SymmetricKey(key->getKeyBits().const_byte_str(), key->getKeyBits().size()); Botan::Algorithm_Factory& af = Botan::global_state().algorithm_factory(); try { unwrapped = Botan::rfc5649_keyunwrap(wrapped, botanKey, af); } catch (...) { ERROR_MSG("AES key unwrap failed"); return false; } out.resize(unwrapped.size()); #if BOTAN_VERSION_MINOR == 11 memcpy(&out[0], unwrapped.data(), out.size()); #else memcpy(&out[0], unwrapped.begin(), out.size()); #endif return true; } #endif else { ERROR_MSG("unknown AES key wrap mode %i", mode); return false; } }
void JSWebGLRenderingContextBase::visitAdditionalChildren(SlotVisitor& visitor) { visitor.addOpaqueRoot(&wrapped()); }
Handle<Value> OSMObjectWrap::get_user(Local<String> property,const AccessorInfo& info) { HandleScope scope; return scope.Close(String::New(wrapped(info.This()).user())); }
void JSIDBIndex::visitAdditionalChildren(SlotVisitor& visitor) { visitor.addOpaqueRoot(&static_cast<IDBIndex&>(wrapped()).modernObjectStore()); }
Handle<Value> OSMObjectWrap::get_visible(Local<String> property,const AccessorInfo& info) { HandleScope scope; return scope.Close(Boolean::New(wrapped(info.This()).visible())); }
Handle<Value> OSMObjectWrap::get_timestamp(Local<String> property,const AccessorInfo& info) { HandleScope scope; return scope.Close(Number::New(wrapped(info.This()).timestamp())); }
void JSDocument::visitAdditionalChildren(SlotVisitor& visitor) { visitor.addOpaqueRoot(wrapped().scriptExecutionContext()); }
Variant HHVM_FUNCTION(json_decode, const String& json, bool assoc /* = false */, int64_t depth /* = 512 */, int64_t options /* = 0 */) { json_set_last_error_code(json_error_codes::JSON_ERROR_NONE); if (json.empty()) { return init_null(); } const int64_t supported_options = k_JSON_FB_LOOSE | k_JSON_FB_COLLECTIONS | k_JSON_FB_STABLE_MAPS | k_JSON_BIGINT_AS_STRING; int64_t parser_options = options & supported_options; Variant z; if (JSON_parser(z, json.data(), json.size(), assoc, depth, parser_options)) { return z; } String trimmed = HHVM_FN(trim)(json, "\t\n\r "); if (trimmed.size() == 4) { if (!strcasecmp(trimmed.data(), "null")) { json_set_last_error_code(json_error_codes::JSON_ERROR_NONE); return init_null(); } if (!strcasecmp(trimmed.data(), "true")) { json_set_last_error_code(json_error_codes::JSON_ERROR_NONE); return true; } } else if (trimmed.size() == 5 && !strcasecmp(trimmed.data(), "false")) { json_set_last_error_code(json_error_codes::JSON_ERROR_NONE); return false; } int64_t p; double d; DataType type = json.get()->isNumericWithVal(p, d, 0); if (type == KindOfInt64) { json_set_last_error_code(json_error_codes::JSON_ERROR_NONE); return p; } else if (type == KindOfDouble) { json_set_last_error_code(json_error_codes::JSON_ERROR_NONE); if ((options & k_JSON_BIGINT_AS_STRING) && (json.toInt64() == LLONG_MAX || json.toInt64() == LLONG_MIN) && errno == ERANGE) { // Overflow bool is_float = false; for (int i = (trimmed[0] == '-' ? 1 : 0); i < trimmed.size(); ++i) { if (trimmed[i] < '0' || trimmed[i] > '9') { is_float = true; break; } } if (!is_float) { return trimmed; } } return d; } char ch0 = json.charAt(0); if (json.size() > 1 && ch0 == '"' && json.charAt(json.size() - 1) == '"') { json_set_last_error_code(json_error_codes::JSON_ERROR_NONE); // Wrap the string in an array to allow the JSON_parser to handle // things like unicode escape sequences, then unwrap to get result String wrapped("["); wrapped += json + "]"; // Stick to a normal hhvm array for the wrapper const int64_t mask = ~(k_JSON_FB_COLLECTIONS | k_JSON_FB_STABLE_MAPS); if (JSON_parser(z, wrapped.data(), wrapped.size(), false, depth, parser_options & mask) && z.isArray()) { Array arr = z.toArray(); if ((arr.size() == 1) && arr.exists(0)) { return arr[0]; } // The input string could be something like: "foo","bar" // Which will parse inside the [] wrapper, but be invalid json_set_last_error_code(json_error_codes::JSON_ERROR_SYNTAX); } } if ((options & k_JSON_FB_LOOSE) && json.size() > 1 && ch0 == '\'' && json.charAt(json.size() - 1) == '\'') { json_set_last_error_code(json_error_codes::JSON_ERROR_NONE); return json.substr(1, json.size() - 2); } assert(json_get_last_error_code() != json_error_codes::JSON_ERROR_NONE); return init_null(); }
JSValue JSDataTransfer::types(ExecState& state) const { Vector<String> types = wrapped().types(); return types.isEmpty() ? jsNull() : jsArray(&state, globalObject(), types); }
Handle<Value> OSMNodeWrap::get_lat(Local<String> property,const AccessorInfo& info) { HandleScope scope; return scope.Close(Number::New(wrapped(info.This()).lat())); }
void JSVideoTrack::visitAdditionalChildren(SlotVisitor& visitor) { visitor.addOpaqueRoot(root(&wrapped())); }
JSC::JSValue JSMessagePort::postMessage(JSC::ExecState& state) { return handlePostMessage(state, &wrapped()); }
void JSMessagePort::visitAdditionalChildren(SlotVisitor& visitor) { // If we have a locally entangled port, we can directly mark it as reachable. Ports that are remotely entangled are marked in-use by markActiveObjectsForContext(). if (MessagePort* port = wrapped().locallyEntangledPort()) visitor.addOpaqueRoot(port); }