⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242963 in webkit


Ignore:
Timestamp:
Mar 14, 2019, 1:56:18 PM (7 years ago)
Author:
Brent Fulgham
Message:

Move CommonCrypto SPI declarations to an appropriate PAL/spi header
https://bugs.webkit.org/show_bug.cgi?id=195754
<rdar://problem/48591957>

Reviewed by Jiewen Tan.

Move the forward declarations of various CommonCrypto SPI to an appropriate PAL/spi header.
Update the const correctness of one function call to match new SDK declaration.

No tests because there are no changes in behavior.

Source/WebCore:

  • crypto/CommonCryptoUtilities.h:
  • crypto/mac/CryptoAlgorithmHKDFMac.cpp:

(WebCore::CryptoAlgorithmHKDF::platformDeriveBits):

Source/WebCore/PAL:

  • PAL.xcodeproj/project.pbxproj:
  • pal/spi/cocoa/CommonCryptoSPI.h: Copied from Source/WebCore/crypto/CommonCryptoUtilities.h.
Location:
trunk/Source/WebCore
Files:
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242960 r242963  
     12019-03-14  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Move CommonCrypto SPI declarations to an appropriate PAL/spi header
     4        https://bugs.webkit.org/show_bug.cgi?id=195754
     5        <rdar://problem/48591957>
     6
     7        Reviewed by Jiewen Tan.
     8
     9        Move the forward declarations of various CommonCrypto SPI to an appropriate PAL/spi header.
     10        Update the const correctness of one function call to match new SDK declaration.
     11
     12        No tests because there are no changes in behavior.
     13
     14        * crypto/CommonCryptoUtilities.h:
     15        * crypto/mac/CryptoAlgorithmHKDFMac.cpp:
     16        (WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
     17
    1182019-03-14  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebCore/PAL/ChangeLog

    r242918 r242963  
     12019-03-14  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Move CommonCrypto SPI declarations to an appropriate PAL/spi header
     4        https://bugs.webkit.org/show_bug.cgi?id=195754
     5        <rdar://problem/48591957>
     6
     7        Reviewed by Jiewen Tan.
     8
     9        Move the forward declarations of various CommonCrypto SPI to an appropriate PAL/spi header.
     10        Update the const correctness of one function call to match new SDK declaration.
     11
     12        No tests because there are no changes in behavior.
     13
     14        * PAL.xcodeproj/project.pbxproj:
     15        * pal/spi/cocoa/CommonCryptoSPI.h: Copied from Source/WebCore/crypto/CommonCryptoUtilities.h.
     16
    1172019-03-13  Keith Rollin  <krollin@apple.com>
    218
  • trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj

    r242325 r242963  
    9999                0C7785A11F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 0C7785881F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h */; };
    100100                0CF99CA41F736375007EE793 /* MediaTimeAVFoundation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C00CFD11F68CE4600AAC26D /* MediaTimeAVFoundation.cpp */; };
     101                7A36D0F9223AD9AB00B0522E /* CommonCryptoSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */; };
    101102                0CF99CA81F738437007EE793 /* CoreMediaSoftLink.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0CF99CA61F738436007EE793 /* CoreMediaSoftLink.cpp */; };
    102103                0CF99CA91F738437007EE793 /* CoreMediaSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 0CF99CA71F738437007EE793 /* CoreMediaSoftLink.h */; };
     
    182183                0C2DA0691F33CA8400DBC317 /* CFNetworkSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFNetworkSPI.h; sourceTree = "<group>"; };
    183184                0C2DA06A1F33CA8400DBC317 /* CFUtilitiesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CFUtilitiesSPI.h; sourceTree = "<group>"; };
     185                7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoSPI.h; sourceTree = "<group>"; };
    184186                0C2DA06B1F33CA8400DBC317 /* CoreAudioSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreAudioSPI.h; sourceTree = "<group>"; };
    185187                0C2DA06C1F33CA8400DBC317 /* CoreMediaSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreMediaSPI.h; sourceTree = "<group>"; };
     
    387389                                0C2DA1221F3BEB4900DBC317 /* AVKitSPI.h */,
    388390                                0C2DA1231F3BEB4900DBC317 /* CFNSURLConnectionSPI.h */,
     391                                7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */,
    389392                                0C2DA1241F3BEB4900DBC317 /* CoreTextSPI.h */,
    390393                                0C2DA1251F3BEB4900DBC317 /* DataDetectorsCoreSPI.h */,
     
    680683                                0C5FFF0C1F78D990009EFF1A /* Clock.h in Headers */,
    681684                                0C5FFF101F78D9DA009EFF1A /* ClockCM.h in Headers */,
     685                                7A36D0F9223AD9AB00B0522E /* CommonCryptoSPI.h in Headers */,
    682686                                1C09D0581E31C57E00725F18 /* config.h in Headers */,
    683687                                0C2DA0711F33CA8400DBC317 /* CoreAudioSPI.h in Headers */,
  • trunk/Source/WebCore/PAL/pal/spi/cocoa/CommonCryptoSPI.h

    r242962 r242963  
    11/*
    2  * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030#endif
    3131
    32 #if ENABLE(WEB_CRYPTO)
    33 
    34 #include "CryptoAlgorithmIdentifier.h"
    35 #include <CommonCrypto/CommonCryptor.h>
    36 #include <CommonCrypto/CommonRandom.h>
    37 #include <wtf/Vector.h>
    38 
    3932#if USE(APPLE_INTERNAL_SDK)
    4033#include <CommonCrypto/CommonCryptorSPI.h>
    4134#include <CommonCrypto/CommonECCryptor.h>
    42 // FIXME: <rdar://problem/31508959>
    43 // #include <CommonCrypto/CommonKeyDerivationSPI.h>
     35#include <CommonCrypto/CommonKeyDerivationSPI.h>
    4436#include <CommonCrypto/CommonRSACryptor.h>
     37
     38#if HAVE(CCRSAGetCRTComponents)
     39#include <CommonCrypto/CommonRSACryptorSPI.h>
    4540#endif
    4641
    47 #if USE(APPLE_INTERNAL_SDK) && HAVE(CCRSAGetCRTComponents)
    48 #include <CommonCrypto/CommonRSACryptorSPI.h>
    49 #endif
     42#else
    5043
    5144#ifndef _CC_RSACRYPTOR_H_
     
    110103extern "C" CCCryptorStatus CCECCryptorGeneratePair(size_t keysize, CCECCryptorRef *publicKey, CCECCryptorRef *privateKey);
    111104extern "C" void CCECCryptorRelease(CCECCryptorRef key);
     105#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
     106extern "C" CCCryptorStatus CCECCryptorImportKey(CCECKeyExternalFormat format, const void *keyPackage, size_t keyPackageLen, CCECKeyType keyType, CCECCryptorRef *key);
     107#else
    112108extern "C" CCCryptorStatus CCECCryptorImportKey(CCECKeyExternalFormat format, void *keyPackage, size_t keyPackageLen, CCECKeyType keyType, CCECCryptorRef *key);
     109#endif
    113110extern "C" CCCryptorStatus CCECCryptorExportKey(CCECKeyExternalFormat format, void *keyPackage, size_t *keyPackageLen, CCECKeyType keyType, CCECCryptorRef key);
    114111extern "C" int CCECGetKeySize(CCECCryptorRef key);
     
    128125extern "C" CCStatus CCKeyDerivationHMac(CCKDFAlgorithm algorithm, CCDigestAlgorithm digest, unsigned rounds, const void *keyDerivationKey, size_t keyDerivationKeyLen, const void *label, size_t labelLen, const void *context, size_t contextLen, const void *iv, size_t ivLen, const void *salt, size_t saltLen, void *derivedKey, size_t derivedKeyLen);
    129126
    130 #if !USE(APPLE_INTERNAL_SDK)
    131127extern "C" CCCryptorStatus CCCryptorGCM(CCOperation op, CCAlgorithm alg, const void* key, size_t keyLength, const void* iv, size_t ivLen, const void* aData, size_t aDataLen, const void* dataIn, size_t dataInLength, void* dataOut, void* tag, size_t* tagLength);
    132128extern "C" CCCryptorStatus CCRSACryptorCreateFromData(CCRSAKeyType keyType, const uint8_t *modulus, size_t modulusLength, const uint8_t *exponent, size_t exponentLength, const uint8_t *p, size_t pLength, const uint8_t *q, size_t qLength, CCRSACryptorRef *ref);
    133 #endif
    134129
    135 namespace WebCore {
    136 
    137 #if !HAVE(CCRSAGetCRTComponents)
    138 
    139 // Only need CCBigNum for the code used when we don't have CCRSAGetCRTComponents.
    140 class CCBigNum {
    141 public:
    142     CCBigNum(const uint8_t*, size_t);
    143     ~CCBigNum();
    144 
    145     CCBigNum(const CCBigNum&);
    146     CCBigNum(CCBigNum&&);
    147     CCBigNum& operator=(const CCBigNum&);
    148     CCBigNum& operator=(CCBigNum&&);
    149 
    150     Vector<uint8_t> data() const;
    151 
    152     CCBigNum operator-(uint32_t) const;
    153     CCBigNum operator%(const CCBigNum&) const;
    154     CCBigNum inverse(const CCBigNum& modulus) const;
    155 
    156 private:
    157     CCBigNum(CCBigNumRef);
    158 
    159     CCBigNumRef m_number;
    160 };
    161 
    162 #endif
    163 
    164 bool getCommonCryptoDigestAlgorithm(CryptoAlgorithmIdentifier, CCDigestAlgorithm&);
    165 
    166 } // namespace WebCore
    167 
    168 #endif // ENABLE(WEB_CRYPTO)
     130#endif // !USE(APPLE_INTERNAL_SDK)
  • trunk/Source/WebCore/crypto/CommonCryptoUtilities.h

    r238754 r242963  
    2626#pragma once
    2727
    28 #if (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300)
    29 #define HAVE_CCRSAGetCRTComponents 1
    30 #endif
    31 
    3228#if ENABLE(WEB_CRYPTO)
    3329
     
    3531#include <CommonCrypto/CommonCryptor.h>
    3632#include <CommonCrypto/CommonRandom.h>
     33#include <pal/spi/cocoa/CommonCryptoSPI.h>
    3734#include <wtf/Vector.h>
    38 
    39 #if USE(APPLE_INTERNAL_SDK)
    40 #include <CommonCrypto/CommonCryptorSPI.h>
    41 #include <CommonCrypto/CommonECCryptor.h>
    42 // FIXME: <rdar://problem/31508959>
    43 // #include <CommonCrypto/CommonKeyDerivationSPI.h>
    44 #include <CommonCrypto/CommonRSACryptor.h>
    45 #endif
    46 
    47 #if USE(APPLE_INTERNAL_SDK) && HAVE(CCRSAGetCRTComponents)
    48 #include <CommonCrypto/CommonRSACryptorSPI.h>
    49 #endif
    50 
    51 #ifndef _CC_RSACRYPTOR_H_
    52 enum {
    53     kCCDigestNone = 0,
    54     kCCDigestSHA1 = 8,
    55     kCCDigestSHA224 = 9,
    56     kCCDigestSHA256 = 10,
    57     kCCDigestSHA384 = 11,
    58     kCCDigestSHA512 = 12,
    59 };
    60 typedef uint32_t CCDigestAlgorithm;
    61 
    62 enum {
    63     ccRSAKeyPublic = 0,
    64     ccRSAKeyPrivate = 1
    65 };
    66 typedef uint32_t CCRSAKeyType;
    67 
    68 enum {
    69     ccPKCS1Padding = 1001,
    70     ccOAEPPadding = 1002,
    71     ccRSAPSSPadding = 1005
    72 };
    73 typedef uint32_t CCAsymmetricPadding;
    74 #endif
    75 
    76 typedef struct _CCBigNumRef *CCBigNumRef;
    77 
    78 typedef struct _CCRSACryptor *CCRSACryptorRef;
    79 extern "C" CCCryptorStatus CCRSACryptorEncrypt(CCRSACryptorRef publicKey, CCAsymmetricPadding padding, const void *plainText, size_t plainTextLen, void *cipherText, size_t *cipherTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType);
    80 extern "C" CCCryptorStatus CCRSACryptorDecrypt(CCRSACryptorRef privateKey, CCAsymmetricPadding padding, const void *cipherText, size_t cipherTextLen, void *plainText, size_t *plainTextLen, const void *tagData, size_t tagDataLen, CCDigestAlgorithm digestType);
    81 extern "C" CCCryptorStatus CCRSACryptorSign(CCRSACryptorRef privateKey, CCAsymmetricPadding padding, const void *hashToSign, size_t hashSignLen, CCDigestAlgorithm digestType, size_t saltLen, void *signedData, size_t *signedDataLen);
    82 extern "C" CCCryptorStatus CCRSACryptorVerify(CCRSACryptorRef publicKey, CCAsymmetricPadding padding, const void *hash, size_t hashLen, CCDigestAlgorithm digestType, size_t saltLen, const void *signedData, size_t signedDataLen);
    83 extern "C" CCCryptorStatus CCRSACryptorGeneratePair(size_t keysize, uint32_t e, CCRSACryptorRef *publicKey, CCRSACryptorRef *privateKey);
    84 extern "C" CCRSACryptorRef CCRSACryptorGetPublicKeyFromPrivateKey(CCRSACryptorRef privkey);
    85 extern "C" void CCRSACryptorRelease(CCRSACryptorRef key);
    86 extern "C" CCCryptorStatus CCRSAGetKeyComponents(CCRSACryptorRef rsaKey, uint8_t *modulus, size_t *modulusLength, uint8_t *exponent, size_t *exponentLength, uint8_t *p, size_t *pLength, uint8_t *q, size_t *qLength);
    87 extern "C" CCRSAKeyType CCRSAGetKeyType(CCRSACryptorRef key);
    88 extern "C" CCCryptorStatus CCRSACryptorImport(const void *keyPackage, size_t keyPackageLen, CCRSACryptorRef *key);
    89 extern "C" CCCryptorStatus CCRSACryptorExport(CCRSACryptorRef key, void *out, size_t *outLen);
    90 
    91 #if HAVE(CCRSAGetCRTComponents)
    92 extern "C" CCCryptorStatus CCRSAGetCRTComponentsSizes(CCRSACryptorRef rsaKey, size_t *dpSize, size_t *dqSize, size_t *qinvSize);
    93 extern "C" CCCryptorStatus CCRSAGetCRTComponents(CCRSACryptorRef rsaKey, void *dp, size_t dpSize, void *dq, size_t dqSize, void *qinv, size_t qinvSize);
    94 #endif
    95 
    96 #ifndef _CC_ECCRYPTOR_H_
    97 enum {
    98     ccECKeyPublic = 0,
    99     ccECKeyPrivate = 1,
    100 };
    101 typedef uint32_t CCECKeyType;
    102 
    103 enum {
    104     kCCImportKeyBinary = 0,
    105 };
    106 typedef uint32_t CCECKeyExternalFormat;
    107 #endif
    108 
    109 typedef struct _CCECCryptor *CCECCryptorRef;
    110 extern "C" CCCryptorStatus CCECCryptorGeneratePair(size_t keysize, CCECCryptorRef *publicKey, CCECCryptorRef *privateKey);
    111 extern "C" void CCECCryptorRelease(CCECCryptorRef key);
    112 extern "C" CCCryptorStatus CCECCryptorImportKey(CCECKeyExternalFormat format, void *keyPackage, size_t keyPackageLen, CCECKeyType keyType, CCECCryptorRef *key);
    113 extern "C" CCCryptorStatus CCECCryptorExportKey(CCECKeyExternalFormat format, void *keyPackage, size_t *keyPackageLen, CCECKeyType keyType, CCECCryptorRef key);
    114 extern "C" int CCECGetKeySize(CCECCryptorRef key);
    115 extern "C" CCCryptorStatus CCECCryptorCreateFromData(size_t keySize, uint8_t *qX, size_t qXLength, uint8_t *qY, size_t qYLength, CCECCryptorRef *ref);
    116 extern "C" CCCryptorStatus CCECCryptorGetKeyComponents(CCECCryptorRef ecKey, size_t *keySize, uint8_t *qX, size_t *qXLength, uint8_t *qY, size_t *qYLength, uint8_t *d, size_t *dLength);
    117 extern "C" CCCryptorStatus CCECCryptorComputeSharedSecret(CCECCryptorRef privateKey, CCECCryptorRef publicKey, void *out, size_t *outLen);
    118 extern "C" CCCryptorStatus CCECCryptorSignHash(CCECCryptorRef privateKey, const void *hashToSign, size_t hashSignLen, void *signedData, size_t *signedDataLen);
    119 extern "C" CCCryptorStatus CCECCryptorVerifyHash(CCECCryptorRef publicKey, const void *hash, size_t hashLen, const void *signedData, size_t signedDataLen, uint32_t *valid);
    120 
    121 #ifndef CommonCrypto_CommonNistKeyDerivation_h
    122 enum {
    123     kCCKDFAlgorithmHKDF = 6
    124 };
    125 typedef uint32_t CCKDFAlgorithm;
    126 #endif
    127 
    128 extern "C" CCStatus CCKeyDerivationHMac(CCKDFAlgorithm algorithm, CCDigestAlgorithm digest, unsigned rounds, const void *keyDerivationKey, size_t keyDerivationKeyLen, const void *label, size_t labelLen, const void *context, size_t contextLen, const void *iv, size_t ivLen, const void *salt, size_t saltLen, void *derivedKey, size_t derivedKeyLen);
    129 
    130 #if !USE(APPLE_INTERNAL_SDK)
    131 extern "C" CCCryptorStatus CCCryptorGCM(CCOperation op, CCAlgorithm alg, const void* key, size_t keyLength, const void* iv, size_t ivLen, const void* aData, size_t aDataLen, const void* dataIn, size_t dataInLength, void* dataOut, void* tag, size_t* tagLength);
    132 extern "C" CCCryptorStatus CCRSACryptorCreateFromData(CCRSAKeyType keyType, const uint8_t *modulus, size_t modulusLength, const uint8_t *exponent, size_t exponentLength, const uint8_t *p, size_t pLength, const uint8_t *q, size_t qLength, CCRSACryptorRef *ref);
    133 #endif
    13435
    13536namespace WebCore {
  • trunk/Source/WebCore/crypto/mac/CryptoAlgorithmHKDFMac.cpp

    r238754 r242963  
    4141    getCommonCryptoDigestAlgorithm(parameters.hashIdentifier, digestAlgorithm);
    4242
     43#pragma clang diagnostic push
     44#pragma clang diagnostic ignored "-Wdeprecated-declarations"
    4345    // <rdar://problem/32439455> Currently, when key data is empty, CCKeyDerivationHMac will bail out.
    4446    if (CCKeyDerivationHMac(kCCKDFAlgorithmHKDF, digestAlgorithm, 0, key.key().data(), key.key().size(), 0, 0, parameters.infoVector().data(), parameters.infoVector().size(), 0, 0, parameters.saltVector().data(), parameters.saltVector().size(), result.data(), result.size()))
    4547        return Exception { OperationError };
     48#pragma clang diagnostic pop
    4649    return WTFMove(result);
    4750}
Note: See TracChangeset for help on using the changeset viewer.