Skip to content

Commit

Permalink
Second attempt to fix the crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum committed Oct 20, 2023
1 parent 2437b59 commit afd0e5c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 102 deletions.
91 changes: 0 additions & 91 deletions source/cms/cms_dec.d
Original file line number Diff line number Diff line change
Expand Up @@ -47,94 +47,3 @@ ubyte[] dataFromCMS(ubyte[] data)
{
return dataFromCMS(cast(DataSource) DataSourceMemory(data.ptr, data.length));
}

/+
import memutils.vector;
public import botan.pubkey.pk_keys;
public import botan.asn1.alg_id;
public import botan.filters.pipe;
import botan.asn1.der_enc;
import botan.asn1.ber_dec;
import botan.asn1.alg_id;
import botan.asn1.asn1_attribute;
import botan.codec.pem;
import botan.pubkey.pk_algs;
import botan.utils.types;
import botan.asn1.ber_dec;
import botan.asn1.oids;
import botan.cert.x509.x509cert;
import botan.cert.x509.x509self;
import botan.pubkey.pk_keys;
import botan.asn1.oids;
static this() {
OIDS.setDefaults();
}
struct MobileProvisionData
{
this(ubyte[] data)
{
this(cast(DataSource) DataSourceMemory(data.ptr, data.length));
}
/++
+ /!\ THE CODE IS MADE UNDER THE ASSUMPTION THE DATA IS TRUSTED TO BE VALID!!!!!
+/
this(DataSource source) {
if (!maybeBER(source) || PEM.matches(source)) {
source = cast(DataSource) DataSourceMemory(PEM.decodeCheckLabel(source, "PKCS7"));
}
Vector!AlgorithmIdentifier alg_ids;
Vector!ubyte plistData;
BERDecoder(source)
.startCons(ASN1Tag.SEQUENCE)
.decodeAndCheck(OIDS.lookup("CMS.SignedData"), "Not a CMS file")
.startCons(ASN1Tag.UNIVERSAL, ASN1Tag.PRIVATE)
// SignedData
.startCons(ASN1Tag.SEQUENCE)
// CMSVersion
.decodeAndCheck!size_t(1, "Unsupported CMS version")
.decodeList!AlgorithmIdentifier(alg_ids, ASN1Tag.SET)
// CertificateList
.startCons(ASN1Tag.SEQUENCE)
.decodeAndCheck(OIDS.lookup("CMS.DataContent"), "Not a mobile provision file")
.startCons(ASN1Tag.UNIVERSAL, ASN1Tag.PRIVATE)
.decode(plistData, ASN1Tag.OCTET_STRING)
.verifyEnd()
.endCons()
.verifyEnd()
.endCons()
.discardRemaining()
.endCons()
.verifyEnd()
.endCons()
.verifyEnd()
.endCons();
import slf4d;
getLogger().info(cast(string) plistData[]);
// auto berDecoder = BERDecoder(source);
// BERObject cmsObject = berDecoder.getNextObject();
// funTest(cmsObject);
}
void funTest(ref BERObject cmsObject, uint sz = 0) {
BERDecoder contentDecoder = BERDecoder(cmsObject.value);
while (contentDecoder.moreItems())
{
import std.stdio;
import std.range;
BERObject innerObject = contentDecoder.getNextObject();
writefln!"%s%s %s"('\t'.repeat(sz), innerObject.type_tag, innerObject.value[]);
if (innerObject.type_tag == ASN1Tag.UNIVERSAL || innerObject.type_tag == ASN1Tag.SEQUENCE) {
funTest(innerObject, sz + 1);
}
}
}
}
// +/
9 changes: 0 additions & 9 deletions source/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,3 @@ int main(string[] args) {

return frontend.run(args);
}

static this() {
version (DigitalMars) {

} else {
static import sse2;
sse2.register();
}
}
3 changes: 3 additions & 0 deletions source/sideload/sign.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Tuple!(PlistDict, PlistDict) sign(
PlistDict files = new PlistDict();
PlistDict files2 = new PlistDict();

static import sse2;
sse2.register();

if (!sha1Hasher) {
sha1Hasher = cast(MDxHashFunction) retrieveHash("SHA-1");
}
Expand Down
9 changes: 7 additions & 2 deletions source/sse2/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module sse2;

import botan.constants;
import botan.engine.engine;
import botan.libstate.libstate;
import botan.utils.cpuid;

import sse2.sha1_sse2;
Expand Down Expand Up @@ -69,7 +70,11 @@ final class SHA256SIMDEngine : Engine
{ return null; }
}

private bool isEngineRegistered = false;

void register() {
import botan.libstate.libstate;
globalState().algorithmFactory().addEngine(new SHA256SIMDEngine);
if (!isEngineRegistered) {
globalState().algorithmFactory().addEngine(new SHA256SIMDEngine);
isEngineRegistered = true;
}
}

0 comments on commit afd0e5c

Please sign in to comment.