瀏覽代碼

SwiftFormat

Brandon Toms 3 年之前
父節點
當前提交
7f7a8d935d
共有 2 個文件被更改,包括 54 次插入54 次删除
  1. 52 52
      Sources/CryptoSwift/ASN1/ASN1Decoder.swift
  2. 2 2
      Sources/CryptoSwift/PEM/DER.swift

+ 52 - 52
Sources/CryptoSwift/ASN1/ASN1Decoder.swift

@@ -49,58 +49,58 @@ extension ASN1 {
       let firstByte = try scanner.consume(length: 1).firstByte
       let firstByte = try scanner.consume(length: 1).firstByte
 
 
       switch firstByte {
       switch firstByte {
-      case IDENTIFIERS.SEQUENCE.rawValue:
-        let length = try scanner.consumeLength()
-        let data = try scanner.consume(length: length)
-        let nodes = try decodeSequence(data: data)
-        return .sequence(nodes: nodes)
-        
-      case IDENTIFIERS.INTERGER.rawValue:
-        let length = try scanner.consumeLength()
-        let data = try scanner.consume(length: length)
-        return .integer(data: data)
-        
-      case IDENTIFIERS.OBJECTID.rawValue:
-        let length = try scanner.consumeLength()
-        let data = try scanner.consume(length: length)
-        return .objectIdentifier(data: data)
-        
-      case IDENTIFIERS.NULL.rawValue:
-        _ = try scanner.consume(length: 1)
-        return .null
-        
-      case IDENTIFIERS.BITSTRING.rawValue:
-        let length = try scanner.consumeLength()
-
-        // There's an extra byte (0x00) after the bit string length in all the keys I've encountered.
-        // I couldn't find a specification that referenced this extra byte, but let's consume it and discard it.
-        _ = try scanner.consume(length: 1)
-
-        let data = try scanner.consume(length: length - 1)
-        return .bitString(data: data)
-      
-      case IDENTIFIERS.OCTETSTRING.rawValue:
-        let length = try scanner.consumeLength()
-        let data = try scanner.consume(length: length)
-        return .octetString(data: data)
-        
-      case IDENTIFIERS.EC_OBJECT.rawValue:
-        let length = try scanner.consumeLength()
-        let data = try scanner.consume(length: length)
-        return .objectIdentifier(data: data)
-        
-      case IDENTIFIERS.EC_BITS.rawValue:
-        let length = try scanner.consumeLength()
-
-        // There's an extra byte (0x00) after the bit string length in all the keys I've encountered.
-        // I couldn't find a specification that referenced this extra byte, but let's consume it and discard it.
-        _ = try scanner.consume(length: 1)
-
-        let data = try scanner.consume(length: length - 1)
-        return .ecBits(data: data)
-        
-      default:
-        throw DecodingError.invalidType(value: firstByte)
+        case IDENTIFIERS.SEQUENCE.rawValue:
+          let length = try scanner.consumeLength()
+          let data = try scanner.consume(length: length)
+          let nodes = try decodeSequence(data: data)
+          return .sequence(nodes: nodes)
+
+        case IDENTIFIERS.INTERGER.rawValue:
+          let length = try scanner.consumeLength()
+          let data = try scanner.consume(length: length)
+          return .integer(data: data)
+
+        case IDENTIFIERS.OBJECTID.rawValue:
+          let length = try scanner.consumeLength()
+          let data = try scanner.consume(length: length)
+          return .objectIdentifier(data: data)
+
+        case IDENTIFIERS.NULL.rawValue:
+          _ = try scanner.consume(length: 1)
+          return .null
+
+        case IDENTIFIERS.BITSTRING.rawValue:
+          let length = try scanner.consumeLength()
+
+          // There's an extra byte (0x00) after the bit string length in all the keys I've encountered.
+          // I couldn't find a specification that referenced this extra byte, but let's consume it and discard it.
+          _ = try scanner.consume(length: 1)
+
+          let data = try scanner.consume(length: length - 1)
+          return .bitString(data: data)
+
+        case IDENTIFIERS.OCTETSTRING.rawValue:
+          let length = try scanner.consumeLength()
+          let data = try scanner.consume(length: length)
+          return .octetString(data: data)
+
+        case IDENTIFIERS.EC_OBJECT.rawValue:
+          let length = try scanner.consumeLength()
+          let data = try scanner.consume(length: length)
+          return .objectIdentifier(data: data)
+
+        case IDENTIFIERS.EC_BITS.rawValue:
+          let length = try scanner.consumeLength()
+
+          // There's an extra byte (0x00) after the bit string length in all the keys I've encountered.
+          // I couldn't find a specification that referenced this extra byte, but let's consume it and discard it.
+          _ = try scanner.consume(length: 1)
+
+          let data = try scanner.consume(length: length - 1)
+          return .ecBits(data: data)
+
+        default:
+          throw DecodingError.invalidType(value: firstByte)
       }
       }
     }
     }
 
 

+ 2 - 2
Sources/CryptoSwift/PEM/DER.swift

@@ -29,7 +29,7 @@ internal protocol DERDecodable {
   init(publicDER: Array<UInt8>) throws
   init(publicDER: Array<UInt8>) throws
   /// Attempts to instantiate an instance of your Private Key when given a DER representation of your Private Key
   /// Attempts to instantiate an instance of your Private Key when given a DER representation of your Private Key
   init(privateDER: Array<UInt8>) throws
   init(privateDER: Array<UInt8>) throws
-  
+
   /// Attempts to instantiate a Key when given the ASN1 DER encoded external representation of the Key
   /// Attempts to instantiate a Key when given the ASN1 DER encoded external representation of the Key
   ///
   ///
   /// An example of importing a SecKey RSA key (from Apple's `Security` framework) for use within CryptoSwift
   /// An example of importing a SecKey RSA key (from Apple's `Security` framework) for use within CryptoSwift
@@ -57,7 +57,7 @@ internal protocol DERDecodable {
 }
 }
 
 
 extension DERDecodable {
 extension DERDecodable {
-  public init(rawRepresentation raw:Data) throws {
+  public init(rawRepresentation raw: Data) throws {
     /// The default implementation that makes the original internal initializer publicly available
     /// The default implementation that makes the original internal initializer publicly available
     do { try self.init(privateDER: raw.bytes) } catch {
     do { try self.init(privateDER: raw.bytes) } catch {
       try self.init(publicDER: raw.bytes)
       try self.init(publicDER: raw.bytes)