Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[develop] SDK development #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 17 additions & 17 deletions ownCloudUI/Certificate Metadata/OCCertificate+OpenSSL.m
Expand Up @@ -26,6 +26,8 @@
#import <openssl/conf.h>
#import <openssl/x509v3.h>
#import <openssl/pkcs12.h>
#import <openssl/evp.h>
#import <openssl/core_names.h>

@implementation OCCertificate (OpenSSL)

Expand Down Expand Up @@ -278,32 +280,30 @@ - (NSString *)_iso8601DateStringForASN1Time:(ASN1_TIME *)asn1Time
switch (EVP_PKEY_base_id(evpPKey))
{
case EVP_PKEY_RSA: {
RSA *rsa;
BIGNUM *n = NULL, *e = NULL;
int keyBitLen = 0;

if ((rsa = EVP_PKEY_get1_RSA(evpPKey)) != NULL)
if ((EVP_PKEY_get_bn_param(evpPKey, OSSL_PKEY_PARAM_RSA_EXPONENT, &e) == 1) && (e != NULL))
{
const BIGNUM *n, *e, *d;
RSA_get0_key(rsa, &n, &e, &d);
if (e != NULL)
{
publicKeyDict[OCCertificateMetadataKeyExponentKey] = @(BN_get_word(e)); // Exponent
}
publicKeyDict[OCCertificateMetadataKeyExponentKey] = @(BN_get_word(e)); // Exponent
}

if (n != NULL)
{
publicKeyDict[OCCertificateMetadataKeyBytesKey] = [self _hexStringFromBigNum:n]; // Modulus
}
if ((EVP_PKEY_get_bn_param(evpPKey, OSSL_PKEY_PARAM_RSA_N, &n) == 1) && (n != NULL))
{
publicKeyDict[OCCertificateMetadataKeyBytesKey] = [self _hexStringFromBigNum:n]; // Modulus
}

publicKeyDict[OCCertificateMetadataKeySizeInBitsKey] = @(RSA_size(rsa)*8); // Key size in bits
if ((keyBitLen = EVP_PKEY_get_security_bits(evpPKey)) != 0)
{
publicKeyDict[OCCertificateMetadataKeySizeInBitsKey] = @(keyBitLen); // Key size in bits
}
}
break;
break;

case EVP_PKEY_DSA:
case EVP_PKEY_DH:
case EVP_PKEY_EC:
default: {

if (EVP_PKEY_print_public(bio, evpPKey, 0, NULL) > 0)
{
long availableBytes;
Expand All @@ -320,7 +320,7 @@ - (NSString *)_iso8601DateStringForASN1Time:(ASN1_TIME *)asn1Time
}
}
}
break;
break;
}

BIO_free(bio);
Expand Down Expand Up @@ -444,7 +444,7 @@ - (NSString *)_iso8601DateStringForASN1Time:(ASN1_TIME *)asn1Time
{
*error = OCError(OCErrorCertificateInvalid);
}

return (metaData);
}

Expand Down
2 changes: 1 addition & 1 deletion tools/ocstringstool/ocstringstool/main.swift
Expand Up @@ -46,7 +46,7 @@ switch command {
exit(-1)
}

//MARK: - Commands
// MARK: - Commands
func commandNormalize(rootPath locRootPath: String) {
let locRootURL = NSURL(fileURLWithPath: locRootPath)
var convertedFilesCount = 0
Expand Down