Skip to content

Commit d9b4cc3

Browse files
committed
Revert "crypto: add SPKAC support"
This reverts commit 7f66e44.
1 parent aa94450 commit d9b4cc3

7 files changed

Lines changed: 0 additions & 287 deletions

File tree

β€Žlib/crypto.jsβ€Ž

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -573,30 +573,6 @@ function pbkdf2(password, salt, iterations, keylen, callback) {
573573
}
574574

575575

576-
exports.Certificate = Certificate;
577-
578-
function Certificate() {
579-
if (!(this instanceof Certificate))
580-
return new Certificate();
581-
582-
this._binding = new binding.Certificate();
583-
}
584-
585-
586-
Certificate.prototype.verifySpkac = function(object) {
587-
return this._binding.verifySpkac(object);
588-
};
589-
590-
591-
Certificate.prototype.exportPublicKey = function(object, encoding) {
592-
return this._binding.exportPublicKey(toBuf(object, encoding));
593-
};
594-
595-
596-
Certificate.prototype.exportChallenge = function(object, encoding) {
597-
return this._binding.exportChallenge(toBuf(object, encoding));
598-
};
599-
600576

601577
exports.randomBytes = randomBytes;
602578
exports.pseudoRandomBytes = pseudoRandomBytes;

β€Žsrc/node_crypto.ccβ€Ž

Lines changed: 0 additions & 181 deletions
Original file line numberDiff line numberDiff line change
@@ -3581,186 +3581,6 @@ void GetHashes(const FunctionCallbackInfo<Value>& args) {
35813581
}
35823582

35833583

3584-
void Certificate::Initialize(Handle<Object> target) {
3585-
HandleScope scope(node_isolate);
3586-
3587-
Local<FunctionTemplate> t = FunctionTemplate::New(New);
3588-
3589-
t->InstanceTemplate()->SetInternalFieldCount(1);
3590-
3591-
NODE_SET_PROTOTYPE_METHOD(t, "verifySpkac", VerifySpkac);
3592-
NODE_SET_PROTOTYPE_METHOD(t, "exportPublicKey", ExportPublicKey);
3593-
NODE_SET_PROTOTYPE_METHOD(t, "exportChallenge", ExportChallenge);
3594-
3595-
target->Set(FIXED_ONE_BYTE_STRING(node_isolate, "Certificate"),
3596-
t->GetFunction());
3597-
}
3598-
3599-
3600-
void Certificate::New(const FunctionCallbackInfo<Value>& args) {
3601-
new Certificate(args.GetIsolate(), args.This());
3602-
}
3603-
3604-
3605-
bool Certificate::VerifySpkac(const char* data, unsigned int len) {
3606-
bool rc = false;
3607-
EVP_PKEY* pkey = NULL;
3608-
NETSCAPE_SPKI* spki = NULL;
3609-
3610-
spki = NETSCAPE_SPKI_b64_decode(data, len);
3611-
if (spki == NULL)
3612-
goto exit;
3613-
3614-
pkey = X509_PUBKEY_get(spki->spkac->pubkey);
3615-
if (pkey == NULL)
3616-
goto exit;
3617-
3618-
rc = NETSCAPE_SPKI_verify(spki, pkey) > 0;
3619-
3620-
exit:
3621-
if (pkey != NULL)
3622-
EVP_PKEY_free(pkey);
3623-
3624-
if (spki != NULL)
3625-
NETSCAPE_SPKI_free(spki);
3626-
3627-
return rc;
3628-
}
3629-
3630-
3631-
void Certificate::VerifySpkac(const FunctionCallbackInfo<Value>& args) {
3632-
HandleScope scope(node_isolate);
3633-
3634-
Certificate* certificate = WeakObject::Unwrap<Certificate>(args.This());
3635-
bool rc = false;
3636-
3637-
if (args.Length() < 1)
3638-
return ThrowTypeError("Missing argument");
3639-
3640-
ASSERT_IS_BUFFER(args[0]);
3641-
3642-
size_t length = Buffer::Length(args[0]);
3643-
if (length == 0)
3644-
return args.GetReturnValue().Set(false);
3645-
3646-
const char* data = Buffer::Data(args[0]);
3647-
assert(data != NULL);
3648-
3649-
rc = certificate->VerifySpkac(data, length) > 0;
3650-
3651-
args.GetReturnValue().Set(rc);
3652-
}
3653-
3654-
3655-
const char* Certificate::ExportPublicKey(const char* data, unsigned int len) {
3656-
char* buf = NULL;
3657-
EVP_PKEY* pkey = NULL;
3658-
NETSCAPE_SPKI* spki = NULL;
3659-
3660-
BIO* bio = BIO_new(BIO_s_mem());
3661-
if (bio == NULL)
3662-
goto exit;
3663-
3664-
spki = NETSCAPE_SPKI_b64_decode(data, len);
3665-
if (spki == NULL)
3666-
goto exit;
3667-
3668-
pkey = NETSCAPE_SPKI_get_pubkey(spki);
3669-
if (pkey == NULL)
3670-
goto exit;
3671-
3672-
if (PEM_write_bio_PUBKEY(bio, pkey) <= 0)
3673-
goto exit;
3674-
3675-
BUF_MEM* ptr;
3676-
BIO_get_mem_ptr(bio, &ptr);
3677-
3678-
buf = new char[ptr->length];
3679-
memcpy(buf, ptr->data, ptr->length);
3680-
3681-
exit:
3682-
if (pkey != NULL)
3683-
EVP_PKEY_free(pkey);
3684-
3685-
if (spki != NULL)
3686-
NETSCAPE_SPKI_free(spki);
3687-
3688-
if (bio != NULL)
3689-
BIO_free_all(bio);
3690-
3691-
return buf;
3692-
}
3693-
3694-
3695-
void Certificate::ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
3696-
HandleScope scope(node_isolate);
3697-
3698-
Certificate* certificate = WeakObject::Unwrap<Certificate>(args.This());
3699-
3700-
if (args.Length() < 1)
3701-
return ThrowTypeError("Missing argument");
3702-
3703-
ASSERT_IS_BUFFER(args[0]);
3704-
3705-
size_t length = Buffer::Length(args[0]);
3706-
if (length == 0)
3707-
return args.GetReturnValue().SetEmptyString();
3708-
3709-
char* data = Buffer::Data(args[0]);
3710-
assert(data != NULL);
3711-
3712-
const char* pkey = certificate->ExportPublicKey(data, length);
3713-
if (pkey == NULL)
3714-
return args.GetReturnValue().SetEmptyString();
3715-
3716-
Local<Value> out = Encode(pkey, strlen(pkey), BUFFER);
3717-
3718-
delete[] pkey;
3719-
3720-
args.GetReturnValue().Set(out);
3721-
}
3722-
3723-
3724-
const char* Certificate::ExportChallenge(const char* data, unsigned int len) {
3725-
NETSCAPE_SPKI* sp = NULL;
3726-
3727-
sp = NETSCAPE_SPKI_b64_decode(data, len);
3728-
if (sp == NULL)
3729-
return NULL;
3730-
3731-
return reinterpret_cast<const char*>(ASN1_STRING_data(sp->spkac->challenge));
3732-
}
3733-
3734-
3735-
void Certificate::ExportChallenge(const FunctionCallbackInfo<Value>& args) {
3736-
HandleScope scope(node_isolate);
3737-
3738-
Certificate* crt = WeakObject::Unwrap<Certificate>(args.This());
3739-
3740-
if (args.Length() < 1)
3741-
return ThrowTypeError("Missing argument");
3742-
3743-
ASSERT_IS_BUFFER(args[0]);
3744-
3745-
size_t len = Buffer::Length(args[0]);
3746-
if (len == 0)
3747-
return args.GetReturnValue().SetEmptyString();
3748-
3749-
char* data = Buffer::Data(args[0]);
3750-
assert(data != NULL);
3751-
3752-
const char* cert = crt->ExportChallenge(data, len);
3753-
if (cert == NULL)
3754-
return args.GetReturnValue().SetEmptyString();
3755-
3756-
Local<Value> outString = Encode(cert, strlen(cert), BUFFER);
3757-
3758-
delete[] cert;
3759-
3760-
args.GetReturnValue().Set(outString);
3761-
}
3762-
3763-
37643584
void InitCryptoOnce() {
37653585
SSL_library_init();
37663586
OpenSSL_add_all_algorithms();
@@ -3801,7 +3621,6 @@ void InitCrypto(Handle<Object> target,
38013621
Hash::Initialize(env, target);
38023622
Sign::Initialize(env, target);
38033623
Verify::Initialize(env, target);
3804-
Certificate::Initialize(target);
38053624

38063625
NODE_SET_METHOD(target, "PBKDF2", PBKDF2);
38073626
NODE_SET_METHOD(target, "randomBytes", RandomBytes<false>);

β€Žsrc/node_crypto.hβ€Ž

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -533,26 +533,6 @@ class DiffieHellman : public WeakObject {
533533
DH* dh;
534534
};
535535

536-
class Certificate : public WeakObject {
537-
public:
538-
static void Initialize(v8::Handle<v8::Object> target);
539-
540-
v8::Handle<v8::Value> CertificateInit(const char* sign_type);
541-
bool VerifySpkac(const char* data, unsigned int len);
542-
const char* ExportPublicKey(const char* data, unsigned int len);
543-
const char* ExportChallenge(const char* data, unsigned int len);
544-
545-
protected:
546-
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
547-
static void VerifySpkac(const v8::FunctionCallbackInfo<v8::Value>& args);
548-
static void ExportPublicKey(const v8::FunctionCallbackInfo<v8::Value>& args);
549-
static void ExportChallenge(const v8::FunctionCallbackInfo<v8::Value>& args);
550-
551-
Certificate(v8::Isolate* isolate, v8::Local<v8::Object> wrap)
552-
: WeakObject(isolate, wrap) {
553-
}
554-
};
555-
556536
bool EntropySource(unsigned char* buffer, size_t length);
557537
void InitCrypto(v8::Handle<v8::Object> target);
558538

β€Žtest/fixtures/spkac.failβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žtest/fixtures/spkac.pemβ€Ž

Lines changed: 0 additions & 6 deletions
This file was deleted.

β€Žtest/fixtures/spkac.validβ€Ž

Lines changed: 0 additions & 1 deletion
This file was deleted.

β€Žtest/simple/test-crypto-certificate.jsβ€Ž

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
Β (0)