diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c76682f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +DerivedData/ +.DS_Store +xcuserdata/ \ No newline at end of file diff --git a/NearDrop.xcodeproj/project.pbxproj b/NearDrop.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f508cdb --- /dev/null +++ b/NearDrop.xcodeproj/project.pbxproj @@ -0,0 +1,497 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 698DFAE629E2F91A0064F247 /* NearbyConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 698DFAE529E2F91A0064F247 /* NearbyConnection.swift */; }; + 698DFB0329E362140064F247 /* NDNotificationCenterHackery.m in Sources */ = {isa = PBXBuildFile; fileRef = 698DFB0229E362140064F247 /* NDNotificationCenterHackery.m */; }; + 69D2C32D29E77F2200EC7E30 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 69D2C32B29E77F2200EC7E30 /* Localizable.strings */; }; + 69D2C32F29E7898C00EC7E30 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 69D2C32E29E7898C00EC7E30 /* MainMenu.xib */; }; + 69D2C33829E78DF400EC7E30 /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 69D2C33629E78DF400EC7E30 /* Localizable.stringsdict */; }; + 69DA9A1229E0BF5100A442DA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A1129E0BF5100A442DA /* AppDelegate.swift */; }; + 69DA9A1429E0BF5200A442DA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 69DA9A1329E0BF5200A442DA /* Assets.xcassets */; }; + 69DA9A1F29E0C0B300A442DA /* NearbyConnectionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A1E29E0C0B300A442DA /* NearbyConnectionManager.swift */; }; + 69DA9A2129E0CC4E00A442DA /* Data+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A2029E0CC4E00A442DA /* Data+Extensions.swift */; }; + 69DA9A2329E17F0400A442DA /* InboundNearbyConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A2229E17F0400A442DA /* InboundNearbyConnection.swift */; }; + 69DA9A2629E189EF00A442DA /* SwiftProtobuf in Frameworks */ = {isa = PBXBuildFile; productRef = 69DA9A2529E189EF00A442DA /* SwiftProtobuf */; }; + 69DA9A2E29E18CB500A442DA /* ukey.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A2829E18CB500A442DA /* ukey.pb.swift */; }; + 69DA9A2F29E18CB500A442DA /* wire_format.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A2929E18CB500A442DA /* wire_format.pb.swift */; }; + 69DA9A3029E18CB500A442DA /* device_to_device_messages.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A2A29E18CB500A442DA /* device_to_device_messages.pb.swift */; }; + 69DA9A3129E18CB500A442DA /* offline_wire_formats.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A2B29E18CB500A442DA /* offline_wire_formats.pb.swift */; }; + 69DA9A3229E18CB500A442DA /* securegcm.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A2C29E18CB500A442DA /* securegcm.pb.swift */; }; + 69DA9A3329E18CB500A442DA /* securemessage.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DA9A2D29E18CB500A442DA /* securemessage.pb.swift */; }; + 69DA9A3629E1994C00A442DA /* SwiftECC in Frameworks */ = {isa = PBXBuildFile; productRef = 69DA9A3529E1994C00A442DA /* SwiftECC */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 698DFAFF29E353220064F247 /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 698DFAE529E2F91A0064F247 /* NearbyConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearbyConnection.swift; sourceTree = ""; }; + 698DFAED29E353220064F247 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; }; + 698DFAEF29E353220064F247 /* UserNotificationsUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotificationsUI.framework; path = System/Library/Frameworks/UserNotificationsUI.framework; sourceTree = SDKROOT; }; + 698DFB0029E362140064F247 /* NearDrop-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NearDrop-Bridging-Header.h"; sourceTree = ""; }; + 698DFB0129E362140064F247 /* NDNotificationCenterHackery.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NDNotificationCenterHackery.h; sourceTree = ""; }; + 698DFB0229E362140064F247 /* NDNotificationCenterHackery.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NDNotificationCenterHackery.m; sourceTree = ""; }; + 69D2C32C29E77F2200EC7E30 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = ""; }; + 69D2C32E29E7898C00EC7E30 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; + 69D2C33029E789AF00EC7E30 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/Localizable.strings; sourceTree = ""; }; + 69D2C33729E78DF400EC7E30 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = Base; path = Base.lproj/Localizable.stringsdict; sourceTree = ""; }; + 69D2C33929E78DFD00EC7E30 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = ru; path = ru.lproj/Localizable.stringsdict; sourceTree = ""; }; + 69DA9A0E29E0BF5100A442DA /* NearDrop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NearDrop.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 69DA9A1129E0BF5100A442DA /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 69DA9A1329E0BF5200A442DA /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 69DA9A1829E0BF5200A442DA /* NearDrop.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NearDrop.entitlements; sourceTree = ""; }; + 69DA9A1E29E0C0B300A442DA /* NearbyConnectionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearbyConnectionManager.swift; sourceTree = ""; }; + 69DA9A2029E0CC4E00A442DA /* Data+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Extensions.swift"; sourceTree = ""; }; + 69DA9A2229E17F0400A442DA /* InboundNearbyConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboundNearbyConnection.swift; sourceTree = ""; }; + 69DA9A2829E18CB500A442DA /* ukey.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ukey.pb.swift; sourceTree = ""; }; + 69DA9A2929E18CB500A442DA /* wire_format.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = wire_format.pb.swift; sourceTree = ""; }; + 69DA9A2A29E18CB500A442DA /* device_to_device_messages.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = device_to_device_messages.pb.swift; sourceTree = ""; }; + 69DA9A2B29E18CB500A442DA /* offline_wire_formats.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = offline_wire_formats.pb.swift; sourceTree = ""; }; + 69DA9A2C29E18CB500A442DA /* securegcm.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = securegcm.pb.swift; sourceTree = ""; }; + 69DA9A2D29E18CB500A442DA /* securemessage.pb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = securemessage.pb.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 69DA9A0B29E0BF5100A442DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 69DA9A3629E1994C00A442DA /* SwiftECC in Frameworks */, + 69DA9A2629E189EF00A442DA /* SwiftProtobuf in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 698DFAEC29E353220064F247 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 698DFAED29E353220064F247 /* UserNotifications.framework */, + 698DFAEF29E353220064F247 /* UserNotificationsUI.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 69DA9A0529E0BF5100A442DA = { + isa = PBXGroup; + children = ( + 69DA9A1029E0BF5100A442DA /* NearDrop */, + 698DFAEC29E353220064F247 /* Frameworks */, + 69DA9A0F29E0BF5100A442DA /* Products */, + ); + sourceTree = ""; + }; + 69DA9A0F29E0BF5100A442DA /* Products */ = { + isa = PBXGroup; + children = ( + 69DA9A0E29E0BF5100A442DA /* NearDrop.app */, + ); + name = Products; + sourceTree = ""; + }; + 69DA9A1029E0BF5100A442DA /* NearDrop */ = { + isa = PBXGroup; + children = ( + 69DA9A2729E18CB500A442DA /* Protobuf */, + 69DA9A1129E0BF5100A442DA /* AppDelegate.swift */, + 69DA9A1329E0BF5200A442DA /* Assets.xcassets */, + 69DA9A1E29E0C0B300A442DA /* NearbyConnectionManager.swift */, + 69D2C33629E78DF400EC7E30 /* Localizable.stringsdict */, + 69D2C32B29E77F2200EC7E30 /* Localizable.strings */, + 69DA9A2229E17F0400A442DA /* InboundNearbyConnection.swift */, + 698DFB0129E362140064F247 /* NDNotificationCenterHackery.h */, + 698DFB0229E362140064F247 /* NDNotificationCenterHackery.m */, + 698DFAE529E2F91A0064F247 /* NearbyConnection.swift */, + 69DA9A2029E0CC4E00A442DA /* Data+Extensions.swift */, + 69DA9A1829E0BF5200A442DA /* NearDrop.entitlements */, + 698DFB0029E362140064F247 /* NearDrop-Bridging-Header.h */, + 69D2C32E29E7898C00EC7E30 /* MainMenu.xib */, + ); + path = NearDrop; + sourceTree = ""; + }; + 69DA9A2729E18CB500A442DA /* Protobuf */ = { + isa = PBXGroup; + children = ( + 69DA9A2829E18CB500A442DA /* ukey.pb.swift */, + 69DA9A2929E18CB500A442DA /* wire_format.pb.swift */, + 69DA9A2A29E18CB500A442DA /* device_to_device_messages.pb.swift */, + 69DA9A2B29E18CB500A442DA /* offline_wire_formats.pb.swift */, + 69DA9A2C29E18CB500A442DA /* securegcm.pb.swift */, + 69DA9A2D29E18CB500A442DA /* securemessage.pb.swift */, + ); + path = Protobuf; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 69DA9A0D29E0BF5100A442DA /* NearDrop */ = { + isa = PBXNativeTarget; + buildConfigurationList = 69DA9A1B29E0BF5200A442DA /* Build configuration list for PBXNativeTarget "NearDrop" */; + buildPhases = ( + 69DA9A0A29E0BF5100A442DA /* Sources */, + 69DA9A0B29E0BF5100A442DA /* Frameworks */, + 69DA9A0C29E0BF5100A442DA /* Resources */, + 698DFAFF29E353220064F247 /* Embed Foundation Extensions */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = NearDrop; + packageProductDependencies = ( + 69DA9A2529E189EF00A442DA /* SwiftProtobuf */, + 69DA9A3529E1994C00A442DA /* SwiftECC */, + ); + productName = NearDrop; + productReference = 69DA9A0E29E0BF5100A442DA /* NearDrop.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 69DA9A0629E0BF5100A442DA /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1430; + LastUpgradeCheck = 1430; + TargetAttributes = { + 69DA9A0D29E0BF5100A442DA = { + CreatedOnToolsVersion = 14.3; + LastSwiftMigration = 1430; + }; + }; + }; + buildConfigurationList = 69DA9A0929E0BF5100A442DA /* Build configuration list for PBXProject "NearDrop" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ru, + ); + mainGroup = 69DA9A0529E0BF5100A442DA; + packageReferences = ( + 69DA9A2429E189EF00A442DA /* XCRemoteSwiftPackageReference "swift-protobuf" */, + 69DA9A3429E1994C00A442DA /* XCRemoteSwiftPackageReference "SwiftECC" */, + ); + productRefGroup = 69DA9A0F29E0BF5100A442DA /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 69DA9A0D29E0BF5100A442DA /* NearDrop */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 69DA9A0C29E0BF5100A442DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 69DA9A1429E0BF5200A442DA /* Assets.xcassets in Resources */, + 69D2C33829E78DF400EC7E30 /* Localizable.stringsdict in Resources */, + 69D2C32D29E77F2200EC7E30 /* Localizable.strings in Resources */, + 69D2C32F29E7898C00EC7E30 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 69DA9A0A29E0BF5100A442DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 69DA9A2E29E18CB500A442DA /* ukey.pb.swift in Sources */, + 698DFB0329E362140064F247 /* NDNotificationCenterHackery.m in Sources */, + 69DA9A2329E17F0400A442DA /* InboundNearbyConnection.swift in Sources */, + 69DA9A1F29E0C0B300A442DA /* NearbyConnectionManager.swift in Sources */, + 69DA9A3029E18CB500A442DA /* device_to_device_messages.pb.swift in Sources */, + 69DA9A3129E18CB500A442DA /* offline_wire_formats.pb.swift in Sources */, + 69DA9A1229E0BF5100A442DA /* AppDelegate.swift in Sources */, + 69DA9A2F29E18CB500A442DA /* wire_format.pb.swift in Sources */, + 69DA9A3329E18CB500A442DA /* securemessage.pb.swift in Sources */, + 69DA9A2129E0CC4E00A442DA /* Data+Extensions.swift in Sources */, + 69DA9A3229E18CB500A442DA /* securegcm.pb.swift in Sources */, + 698DFAE629E2F91A0064F247 /* NearbyConnection.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 69D2C32B29E77F2200EC7E30 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 69D2C32C29E77F2200EC7E30 /* Base */, + 69D2C33029E789AF00EC7E30 /* ru */, + ); + name = Localizable.strings; + sourceTree = ""; + }; + 69D2C33629E78DF400EC7E30 /* Localizable.stringsdict */ = { + isa = PBXVariantGroup; + children = ( + 69D2C33729E78DF400EC7E30 /* Base */, + 69D2C33929E78DFD00EC7E30 /* ru */, + ); + name = Localizable.stringsdict; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 69DA9A1929E0BF5200A442DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.3; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 69DA9A1A29E0BF5200A442DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 13.3; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 69DA9A1C29E0BF5200A442DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = NearDrop/NearDrop.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; + INFOPLIST_KEY_LSUIElement = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSMainNibFile = MainMenu; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = me.grishka.NearDrop; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_OBJC_BRIDGING_HEADER = "NearDrop/NearDrop-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 69DA9A1D29E0BF5200A442DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = NearDrop/NearDrop.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; + INFOPLIST_KEY_LSUIElement = YES; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + INFOPLIST_KEY_NSMainNibFile = MainMenu; + INFOPLIST_KEY_NSPrincipalClass = NSApplication; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 11.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = me.grishka.NearDrop; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_OBJC_BRIDGING_HEADER = "NearDrop/NearDrop-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 69DA9A0929E0BF5100A442DA /* Build configuration list for PBXProject "NearDrop" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 69DA9A1929E0BF5200A442DA /* Debug */, + 69DA9A1A29E0BF5200A442DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 69DA9A1B29E0BF5200A442DA /* Build configuration list for PBXNativeTarget "NearDrop" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 69DA9A1C29E0BF5200A442DA /* Debug */, + 69DA9A1D29E0BF5200A442DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 69DA9A2429E189EF00A442DA /* XCRemoteSwiftPackageReference "swift-protobuf" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/apple/swift-protobuf.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.0.0; + }; + }; + 69DA9A3429E1994C00A442DA /* XCRemoteSwiftPackageReference "SwiftECC" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/leif-ibsen/SwiftECC"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 3.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 69DA9A2529E189EF00A442DA /* SwiftProtobuf */ = { + isa = XCSwiftPackageProductDependency; + package = 69DA9A2429E189EF00A442DA /* XCRemoteSwiftPackageReference "swift-protobuf" */; + productName = SwiftProtobuf; + }; + 69DA9A3529E1994C00A442DA /* SwiftECC */ = { + isa = XCSwiftPackageProductDependency; + package = 69DA9A3429E1994C00A442DA /* XCRemoteSwiftPackageReference "SwiftECC" */; + productName = SwiftECC; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 69DA9A0629E0BF5100A442DA /* Project object */; +} diff --git a/NearDrop.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/NearDrop.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/NearDrop.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/NearDrop.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/NearDrop.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/NearDrop.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/NearDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/NearDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..12467f6 --- /dev/null +++ b/NearDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,41 @@ +{ + "pins" : [ + { + "identity" : "asn1", + "kind" : "remoteSourceControl", + "location" : "https://github.com/leif-ibsen/ASN1", + "state" : { + "revision" : "555922e06f1835863d4c0143eb00d0097bcfc707", + "version" : "2.0.3" + } + }, + { + "identity" : "bigint", + "kind" : "remoteSourceControl", + "location" : "https://github.com/leif-ibsen/BigInt", + "state" : { + "revision" : "47903c6b2dd2cb3b4484d4524676a2ca8723a871", + "version" : "1.9.0" + } + }, + { + "identity" : "swift-protobuf", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-protobuf.git", + "state" : { + "revision" : "0af9125c4eae12a4973fb66574c53a54962a9e1e", + "version" : "1.21.0" + } + }, + { + "identity" : "swiftecc", + "kind" : "remoteSourceControl", + "location" : "https://github.com/leif-ibsen/SwiftECC", + "state" : { + "revision" : "55493f0609f07b24bf6cd52b90898ed1cefb268e", + "version" : "3.5.3" + } + } + ], + "version" : 2 +} diff --git a/NearDrop.xcodeproj/xcshareddata/xcschemes/NearDrop.xcscheme b/NearDrop.xcodeproj/xcshareddata/xcschemes/NearDrop.xcscheme new file mode 100644 index 0000000..3a735a3 --- /dev/null +++ b/NearDrop.xcodeproj/xcshareddata/xcschemes/NearDrop.xcscheme @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NearDrop/AppDelegate.swift b/NearDrop/AppDelegate.swift new file mode 100644 index 0000000..35e3cdc --- /dev/null +++ b/NearDrop/AppDelegate.swift @@ -0,0 +1,44 @@ +// +// AppDelegate.swift +// NearDrop +// +// Created by Grishka on 08.04.2023. +// + +import Cocoa +import UserNotifications + +@main +class AppDelegate: NSObject, NSApplicationDelegate{ + + private var connectionManager:NearbyConnectionManager? + private var statusItem:NSStatusItem? + + func applicationDidFinishLaunching(_ aNotification: Notification) { + let menu=NSMenu() + menu.addItem(withTitle: NSLocalizedString("VisibleToEveryone", value: "Visible to everyone", comment: ""), action: nil, keyEquivalent: "") + menu.addItem(withTitle: String(format: NSLocalizedString("DeviceName", value: "Device name: %@", comment: ""), arguments: [Host.current().localizedName!]), action: nil, keyEquivalent: "") + menu.addItem(NSMenuItem.separator()) + menu.addItem(withTitle: NSLocalizedString("Quit", value: "Quit NearDrop", comment: ""), action: #selector(NSApplication.terminate(_:)), keyEquivalent: "") + statusItem=NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) + statusItem?.button?.image=NSImage(named: "MenuBarIcon") + statusItem?.menu=menu + + let nc=UNUserNotificationCenter.current() + nc.requestAuthorization(options: [.alert, .sound]) { granted, err in + } + let incomingTransfersCategory=NDNotificationCenterHackery.hackedNotificationCategory() + let errorsCategory=UNNotificationCategory(identifier: "ERRORS", actions: [], intentIdentifiers: []) + nc.setNotificationCategories([incomingTransfersCategory, errorsCategory]) + connectionManager=NearbyConnectionManager() + } + + func applicationWillTerminate(_ aNotification: Notification) { + UNUserNotificationCenter.current().removeAllDeliveredNotifications() + } + + func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } +} + diff --git a/NearDrop/Assets.xcassets/AccentColor.colorset/Contents.json b/NearDrop/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/NearDrop/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/1024.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/1024.png new file mode 100644 index 0000000..54f8023 Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/1024.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/128.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/128.png new file mode 100644 index 0000000..d215841 Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/128.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/16.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/16.png new file mode 100644 index 0000000..b4a8027 Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/16.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/256 1.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/256 1.png new file mode 100644 index 0000000..1d1bcc1 Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/256 1.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/256.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/256.png new file mode 100644 index 0000000..1d1bcc1 Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/256.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/32 1.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/32 1.png new file mode 100644 index 0000000..21f8b8f Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/32 1.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/32.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/32.png new file mode 100644 index 0000000..21f8b8f Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/32.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/512 1.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/512 1.png new file mode 100644 index 0000000..858de45 Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/512 1.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/512.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/512.png new file mode 100644 index 0000000..858de45 Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/512.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/64.png b/NearDrop/Assets.xcassets/AppIcon.appiconset/64.png new file mode 100644 index 0000000..7b29321 Binary files /dev/null and b/NearDrop/Assets.xcassets/AppIcon.appiconset/64.png differ diff --git a/NearDrop/Assets.xcassets/AppIcon.appiconset/Contents.json b/NearDrop/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..f6b252f --- /dev/null +++ b/NearDrop/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "filename" : "16.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "filename" : "32.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "filename" : "32 1.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "filename" : "64.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "filename" : "128.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "filename" : "256.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "filename" : "256 1.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "filename" : "512.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "filename" : "512 1.png", + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "filename" : "1024.png", + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/NearDrop/Assets.xcassets/Contents.json b/NearDrop/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/NearDrop/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/NearDrop/Assets.xcassets/MenuBarIcon.imageset/Contents.json b/NearDrop/Assets.xcassets/MenuBarIcon.imageset/Contents.json new file mode 100644 index 0000000..436623c --- /dev/null +++ b/NearDrop/Assets.xcassets/MenuBarIcon.imageset/Contents.json @@ -0,0 +1,25 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "NearbyShare.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "NearbyShare@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "template-rendering-intent" : "template" + } +} \ No newline at end of file diff --git a/NearDrop/Assets.xcassets/MenuBarIcon.imageset/NearbyShare.png b/NearDrop/Assets.xcassets/MenuBarIcon.imageset/NearbyShare.png new file mode 100644 index 0000000..fbac020 Binary files /dev/null and b/NearDrop/Assets.xcassets/MenuBarIcon.imageset/NearbyShare.png differ diff --git a/NearDrop/Assets.xcassets/MenuBarIcon.imageset/NearbyShare@2x.png b/NearDrop/Assets.xcassets/MenuBarIcon.imageset/NearbyShare@2x.png new file mode 100644 index 0000000..f7b74f7 Binary files /dev/null and b/NearDrop/Assets.xcassets/MenuBarIcon.imageset/NearbyShare@2x.png differ diff --git a/NearDrop/Base.lproj/Localizable.strings b/NearDrop/Base.lproj/Localizable.strings new file mode 100644 index 0000000..7a2a9e5 Binary files /dev/null and b/NearDrop/Base.lproj/Localizable.strings differ diff --git a/NearDrop/Base.lproj/Localizable.stringsdict b/NearDrop/Base.lproj/Localizable.stringsdict new file mode 100644 index 0000000..57d2cd7 --- /dev/null +++ b/NearDrop/Base.lproj/Localizable.stringsdict @@ -0,0 +1,22 @@ + + + + + NFiles + + NSStringLocalizedFormatKey + %#@files@ + files + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + d + one + %d file + other + %d files + + + + diff --git a/NearDrop/Data+Extensions.swift b/NearDrop/Data+Extensions.swift new file mode 100644 index 0000000..94e3e18 --- /dev/null +++ b/NearDrop/Data+Extensions.swift @@ -0,0 +1,31 @@ +// +// Data+URLSafeBase64.swift +// NearDrop +// +// Created by Grishka on 08.04.2023. +// + +import Foundation +import CoreFoundation + +extension Data{ + func urlSafeBase64EncodedString() -> String { + return String(base64EncodedString().replacingOccurrences(of: "=", with: "").map { + if $0=="/"{ + return "_" + } else if $0=="+" { + return "-" + } else { + return $0 + } + }) + } + + static func randomData(length: Int) -> Data{ + var data=Data(count: length) + data.withUnsafeMutableBytes { + guard 0 == SecRandomCopyBytes(kSecRandomDefault, length, $0.baseAddress!) else { fatalError() } + } + return data + } +} diff --git a/NearDrop/GenerateProtobuf.sh b/NearDrop/GenerateProtobuf.sh new file mode 100755 index 0000000..964aa88 --- /dev/null +++ b/NearDrop/GenerateProtobuf.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +ls ProtobufSource | xargs protoc --swift_out=Protobuf --proto_path=ProtobufSource diff --git a/NearDrop/InboundNearbyConnection.swift b/NearDrop/InboundNearbyConnection.swift new file mode 100644 index 0000000..5314b40 --- /dev/null +++ b/NearDrop/InboundNearbyConnection.swift @@ -0,0 +1,351 @@ +// +// InboundNearbyConnection.swift +// NearDrop +// +// Created by Grishka on 08.04.2023. +// + +import Foundation +import Network +import CryptoKit +import CommonCrypto +import System + +import SwiftECC +import BigInt + +class InboundNearbyConnection: NearbyConnection{ + + private var currentState:State = .initial + public var delegate:InboundNearbyConnectionDelegate? + private var cipherCommitment:Data? + + enum State{ + case initial, receivedConnectionRequest, sentUkeyServerInit, receivedUkeyClientFinish, sentConnectionResponse, sentPairedKeyResult, receivedPairedKeyResult, waitingForUserConsent, receivingFiles, disconnected + } + + override init(connection: NWConnection, id:String) { + super.init(connection: connection, id: id) + } + + override func handleConnectionClosure() { + super.handleConnectionClosure() + currentState = .disconnected + do{ + try deletePartiallyReceivedFiles() + }catch{ + print("Error deleting partially received files: \(error)") + } + DispatchQueue.main.async { + self.delegate?.connectionWasTerminated(connection: self, error: self.lastError) + } + } + + override internal func processReceivedFrame(frameData:Data){ + do{ + switch currentState { + case .initial: + let frame=try Location_Nearby_Connections_OfflineFrame(serializedData: frameData) + try processConnectionRequestFrame(frame) + case .receivedConnectionRequest: + let msg=try Securegcm_Ukey2Message(serializedData: frameData) + ukeyClientInitMsgData=frameData + try processUkey2ClientInit(msg) + case .sentUkeyServerInit: + let msg=try Securegcm_Ukey2Message(serializedData: frameData) + try processUkey2ClientFinish(msg, raw: frameData) + case .receivedUkeyClientFinish: + let frame=try Location_Nearby_Connections_OfflineFrame(serializedData: frameData) + try processConnectionResponseFrame(frame) + default: + let smsg=try Securemessage_SecureMessage(serializedData: frameData) + try decryptAndProcessReceivedSecureMessage(smsg) + } + }catch{ + lastError=error + print("Deserialization error: \(error)") + protocolError() + } + } + + override internal func processTransferSetupFrame(_ frame:Sharing_Nearby_Frame) throws{ + if frame.hasV1 && frame.v1.hasType, case .cancel = frame.v1.type { + print("Transfer canceled") + try sendDisconnectionAndDisconnect() + return + } + switch currentState{ + case .sentConnectionResponse: + try processPairedKeyEncryptionFrame(frame) + case .sentPairedKeyResult: + try processPairedKeyResultFrame(frame) + case .receivedPairedKeyResult: + try processIntroductionFrame(frame) + default: + print("Unexpected connection state in processTransferSetupFrame: \(currentState)") + print(frame) + } + } + + override func isServer() -> Bool { + return true + } + + override func processFileChunk(frame: Location_Nearby_Connections_PayloadTransferFrame) throws{ + let id=frame.payloadHeader.id + guard let fileInfo=transferredFiles[id] else { throw NearbyError.protocolError("File payload ID \(id) is not known") } + let currentOffset=fileInfo.bytesTransferred + guard frame.payloadChunk.offset==currentOffset else { throw NearbyError.protocolError("Invalid offset into file \(frame.payloadChunk.offset), expected \(currentOffset)") } + guard currentOffset+Int64(frame.payloadChunk.body.count)<=fileInfo.meta.size else { throw NearbyError.protocolError("Transferred file size exceeds previously specified value") } + if frame.payloadChunk.body.count>0{ + try fileInfo.fileHandle?.write(contentsOf: frame.payloadChunk.body) + transferredFiles[id]!.bytesTransferred+=Int64(frame.payloadChunk.body.count) + fileInfo.progress?.completedUnitCount=transferredFiles[id]!.bytesTransferred + }else if (frame.payloadChunk.flags & 1)==1{ + try fileInfo.fileHandle?.close() + transferredFiles[id]!.fileHandle=nil + fileInfo.progress?.unpublish() + transferredFiles.removeValue(forKey: id) + if transferredFiles.isEmpty{ + try sendDisconnectionAndDisconnect() + } + } + } + + private func processConnectionRequestFrame(_ frame:Location_Nearby_Connections_OfflineFrame) throws{ + guard frame.hasV1 && frame.v1.hasConnectionRequest && frame.v1.connectionRequest.hasEndpointInfo else { throw NearbyError.requiredFieldMissing } + guard case .connectionRequest = frame.v1.type else { throw NearbyError.protocolError("Unexpected frame type \(frame.v1.type)") } + let endpointInfo=frame.v1.connectionRequest.endpointInfo + guard endpointInfo.count>17 else { throw NearbyError.protocolError("Endpoint info too short") } + let deviceNameLength=Int(endpointInfo[17]) + guard endpointInfo.count>=deviceNameLength+18 else { throw NearbyError.protocolError("Endpoint info too short to contain the device name") } + guard let deviceName=String(data: endpointInfo[18..<(18+deviceNameLength)], encoding: .utf8) else { throw NearbyError.protocolError("Device name is not valid UTF-8") } + let rawDeviceType:Int=Int(endpointInfo[0] & 7) >> 1 + remoteDeviceInfo=RemoteDeviceInfo(name: deviceName, type: RemoteDeviceInfo.DeviceType.fromRawValue(value: rawDeviceType)) + currentState = .receivedConnectionRequest + } + + private func processUkey2ClientInit(_ msg:Securegcm_Ukey2Message) throws{ + guard msg.hasMessageType, msg.hasMessageData else { throw NearbyError.requiredFieldMissing } + guard case .clientInit = msg.messageType else{ + sendUkey2Alert(type: .badMessageType) + throw NearbyError.ukey2 + } + let clientInit:Securegcm_Ukey2ClientInit + do{ + clientInit=try Securegcm_Ukey2ClientInit(serializedData: msg.messageData) + }catch{ + sendUkey2Alert(type: .badMessageData) + throw NearbyError.ukey2 + } + guard clientInit.version==1 else{ + sendUkey2Alert(type: .badVersion) + throw NearbyError.ukey2 + } + guard clientInit.random.count==32 else{ + sendUkey2Alert(type: .badRandom) + throw NearbyError.ukey2 + } + var found=false + for commitment in clientInit.cipherCommitments{ + if case .p256Sha512 = commitment.handshakeCipher{ + found=true + cipherCommitment=commitment.commitment + break + } + } + guard found else{ + sendUkey2Alert(type: .badHandshakeCipher) + throw NearbyError.ukey2 + } + guard clientInit.nextProtocol=="AES_256_CBC-HMAC_SHA256" else{ + sendUkey2Alert(type: .badNextProtocol) + throw NearbyError.ukey2 + } + + let domain=Domain.instance(curve: .EC256r1) + let (pubKey, privKey)=domain.makeKeyPair() + publicKey=pubKey + privateKey=privKey + + var serverInit=Securegcm_Ukey2ServerInit() + serverInit.version=1 + serverInit.random=Data.randomData(length: 32) + serverInit.handshakeCipher = .p256Sha512 + + var pkey=Securemessage_GenericPublicKey() + pkey.type = .ecP256 + pkey.ecP256PublicKey=Securemessage_EcP256PublicKey() + pkey.ecP256PublicKey.x=Data(pubKey.w.x.asSignedBytes()) + pkey.ecP256PublicKey.y=Data(pubKey.w.y.asSignedBytes()) + serverInit.publicKey=try pkey.serializedData() + + var serverInitMsg=Securegcm_Ukey2Message() + serverInitMsg.messageType = .serverInit + serverInitMsg.messageData=try serverInit.serializedData() + let serverInitData=try serverInitMsg.serializedData() + ukeyServerInitMsgData=serverInitData + sendFrameAsync(serverInitData) + currentState = .sentUkeyServerInit + } + + private func processUkey2ClientFinish(_ msg:Securegcm_Ukey2Message, raw:Data) throws{ + guard msg.hasMessageType, msg.hasMessageData else { throw NearbyError.requiredFieldMissing } + guard case .clientFinish = msg.messageType else { throw NearbyError.ukey2 } + + var sha=SHA512() + sha.update(data: raw) + guard cipherCommitment==Data(sha.finalize()) else { throw NearbyError.ukey2 } + + let clientFinish=try Securegcm_Ukey2ClientFinished(serializedData: msg.messageData) + guard clientFinish.hasPublicKey else {throw NearbyError.requiredFieldMissing } + let clientKey=try Securemessage_GenericPublicKey(serializedData: clientFinish.publicKey) + + try finalizeKeyExchange(peerKey: clientKey) + + currentState = .receivedUkeyClientFinish + } + + private func processConnectionResponseFrame(_ frame:Location_Nearby_Connections_OfflineFrame) throws{ + guard frame.hasV1, frame.v1.hasType else { throw NearbyError.requiredFieldMissing } + if case .connectionResponse = frame.v1.type { + var resp=Location_Nearby_Connections_OfflineFrame() + resp.version = .v1 + resp.v1=Location_Nearby_Connections_V1Frame() + resp.v1.type = .connectionResponse + resp.v1.connectionResponse=Location_Nearby_Connections_ConnectionResponseFrame() + resp.v1.connectionResponse.response = .accept + resp.v1.connectionResponse.status=0 + resp.v1.connectionResponse.osInfo=Location_Nearby_Connections_OsInfo() + resp.v1.connectionResponse.osInfo.type = .apple + sendFrameAsync(try resp.serializedData()) + + encryptionDone=true + + var pairedEncryption=Sharing_Nearby_Frame() + pairedEncryption.version = .v1 + pairedEncryption.v1=Sharing_Nearby_V1Frame() + pairedEncryption.v1.type = .pairedKeyEncryption + pairedEncryption.v1.pairedKeyEncryption=Sharing_Nearby_PairedKeyEncryptionFrame() + // Presumably used for all the phone number stuff that no one needs anyway + pairedEncryption.v1.pairedKeyEncryption.secretIDHash=Data.randomData(length: 6) + pairedEncryption.v1.pairedKeyEncryption.signedData=Data.randomData(length: 72) + try sendTransferSetupFrame(pairedEncryption) + currentState = .sentConnectionResponse + } else { + print("Unhandled offline frame plaintext: \(frame)") + } + } + + private func processPairedKeyEncryptionFrame(_ frame:Sharing_Nearby_Frame) throws{ + guard frame.hasV1, frame.v1.hasPairedKeyEncryption else { throw NearbyError.requiredFieldMissing } + var pairedResult=Sharing_Nearby_Frame() + pairedResult.version = .v1 + pairedResult.v1=Sharing_Nearby_V1Frame() + pairedResult.v1.type = .pairedKeyResult + pairedResult.v1.pairedKeyResult=Sharing_Nearby_PairedKeyResultFrame() + pairedResult.v1.pairedKeyResult.status = .unable + try sendTransferSetupFrame(pairedResult) + currentState = .sentPairedKeyResult + } + + private func processPairedKeyResultFrame(_ frame:Sharing_Nearby_Frame) throws{ + guard frame.hasV1, frame.v1.hasPairedKeyResult else { throw NearbyError.requiredFieldMissing } + currentState = .receivedPairedKeyResult + } + + private func processIntroductionFrame(_ frame:Sharing_Nearby_Frame) throws{ + guard frame.hasV1, frame.v1.hasIntroduction else { throw NearbyError.requiredFieldMissing } + currentState = .waitingForUserConsent + let downloadsDirectory=(try FileManager.default.url(for: .downloadsDirectory, in: .userDomainMask, appropriateFor: nil, create: true)).resolvingSymlinksInPath() + for file in frame.v1.introduction.fileMetadata{ + var dest=downloadsDirectory.appendingPathComponent(file.name) + if FileManager.default.fileExists(atPath: dest.path){ + var counter=1 + var path:String + let ext=dest.pathExtension + let baseUrl=dest.deletingPathExtension() + repeat{ + path="\(baseUrl.path) (\(counter))" + if !ext.isEmpty{ + path+=".\(ext)" + } + counter+=1 + }while FileManager.default.fileExists(atPath: path) + dest=URL(fileURLWithPath: path) + } + let info=InternalFileInfo(meta: FileMetadata(name: file.name, size: file.size, mimeType: file.mimeType), + payloadID: file.payloadID, + destinationURL: dest) + transferredFiles[file.payloadID]=info + } + let metadata=TransferMetadata(files: transferredFiles.map({$0.value.meta})) + DispatchQueue.main.async { + self.delegate?.obtainUserConsent(for: metadata, from: self.remoteDeviceInfo!, connection: self) + } + } + + func submitUserConsent(accepted:Bool){ + DispatchQueue.global(qos: .utility).async { + if accepted{ + self.acceptTransfer() + }else{ + self.rejectTransfer() + } + } + } + + private func acceptTransfer(){ + do{ + for (id, file) in transferredFiles{ + FileManager.default.createFile(atPath: file.destinationURL.path, contents: nil) + let handle=try FileHandle(forWritingTo: file.destinationURL) + transferredFiles[id]!.fileHandle=handle + let progress=Progress() + progress.fileURL=file.destinationURL + progress.totalUnitCount=file.meta.size + progress.kind = .file + progress.isPausable=false + progress.publish() + transferredFiles[id]!.progress=progress + transferredFiles[id]!.created=true + } + + var frame=Sharing_Nearby_Frame() + frame.version = .v1 + frame.v1.type = .response + frame.v1.connectionResponse.status = .accept + currentState = .receivingFiles + try sendTransferSetupFrame(frame) + }catch{ + print("Error \(error)") + protocolError() + } + } + + private func rejectTransfer(){ + var frame=Sharing_Nearby_Frame() + frame.version = .v1 + frame.v1.type = .response + frame.v1.connectionResponse.status = .reject + do{ + try sendTransferSetupFrame(frame) + try sendDisconnectionAndDisconnect() + }catch{ + print("Error \(error)") + protocolError() + } + } + + private func deletePartiallyReceivedFiles() throws{ + for (_, file) in transferredFiles{ + guard file.created else { continue } + try FileManager.default.removeItem(at: file.destinationURL) + } + } +} + +protocol InboundNearbyConnectionDelegate{ + func obtainUserConsent(for transfer:TransferMetadata, from device:RemoteDeviceInfo, connection:InboundNearbyConnection) + func connectionWasTerminated(connection:InboundNearbyConnection, error:Error?) +} diff --git a/NearDrop/MainMenu.xib b/NearDrop/MainMenu.xib new file mode 100644 index 0000000..5e85612 --- /dev/null +++ b/NearDrop/MainMenu.xib @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/NearDrop/NDNotificationCenterHackery.h b/NearDrop/NDNotificationCenterHackery.h new file mode 100644 index 0000000..f108e91 --- /dev/null +++ b/NearDrop/NDNotificationCenterHackery.h @@ -0,0 +1,20 @@ +// +// NDNotificationCenterHackery.h +// NearDrop +// +// Created by Grishka on 10.04.2023. +// + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NDNotificationCenterHackery : NSObject + ++ (UNNotificationCategory*)hackedNotificationCategory; ++ (void)removeDefaultAction:(UNMutableNotificationContent*) content; + +@end + +NS_ASSUME_NONNULL_END diff --git a/NearDrop/NDNotificationCenterHackery.m b/NearDrop/NDNotificationCenterHackery.m new file mode 100644 index 0000000..b9c2d0d --- /dev/null +++ b/NearDrop/NDNotificationCenterHackery.m @@ -0,0 +1,49 @@ +// +// NDNotificationCenterHackery.m +// NearDrop +// +// Created by Grishka on 10.04.2023. +// + +#import +#import +#import "NDNotificationCenterHackery.h" + +@interface UNMutableNotificationCategory : UNNotificationCategory +@property(copy) NSString *actionsMenuTitle; +@property(copy) UNNotificationAction *alternateAction; +@property(copy) NSArray *minimalActions; +@property unsigned long long backgroundStyle; +@property(copy) NSArray *actions; +@end + +@interface UNNotificationIcon : NSObject ++ (id)iconForApplicationIdentifier:(id)arg1; ++ (id)iconAtPath:(id)arg1; ++ (id)iconNamed:(id)arg1; +@end + +@interface UNMutableNotificationContent (NDPrivateAPIs) +@property BOOL hasDefaultAction; +@property(copy) NSString *defaultActionTitle; +@property(copy) NSString *header; +@property (assign,nonatomic) BOOL shouldDisplayActionsInline; +@property (assign,nonatomic) BOOL shouldShowSubordinateIcon; +@property (nonatomic,copy) NSString * accessoryImageName; +@property(copy) UNNotificationIcon *icon; +@end + +@implementation NDNotificationCenterHackery + ++ (UNNotificationCategory*)hackedNotificationCategory{ + UNNotificationAction *accept=[UNNotificationAction actionWithIdentifier:@"ACCEPT" title:NSLocalizedString(@"Accept", nil) options:0]; + UNNotificationAction *decline=[UNNotificationAction actionWithIdentifier:@"DECLINE" title:NSLocalizedString(@"Decline", nil) options:0]; + UNMutableNotificationCategory *category=[UNMutableNotificationCategory categoryWithIdentifier:@"INCOMING_TRANSFERS" actions:@[accept, decline] intentIdentifiers:@[] hiddenPreviewsBodyPlaceholder:@"" options: UNNotificationCategoryOptionCustomDismissAction]; + return category; +} + ++ (void)removeDefaultAction:(UNMutableNotificationContent*) content{ + content.hasDefaultAction=false; +} + +@end diff --git a/NearDrop/NearDrop-Bridging-Header.h b/NearDrop/NearDrop-Bridging-Header.h new file mode 100644 index 0000000..939f4a1 --- /dev/null +++ b/NearDrop/NearDrop-Bridging-Header.h @@ -0,0 +1,5 @@ +// +// Use this file to import your target's public headers that you would like to expose to Swift. +// + +#import "NDNotificationCenterHackery.h" diff --git a/NearDrop/NearDrop.entitlements b/NearDrop/NearDrop.entitlements new file mode 100644 index 0000000..0272206 --- /dev/null +++ b/NearDrop/NearDrop.entitlements @@ -0,0 +1,16 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.files.downloads.read-write + + com.apple.security.files.user-selected.read-only + + com.apple.security.network.client + + com.apple.security.network.server + + + diff --git a/NearDrop/NearbyConnection.swift b/NearDrop/NearbyConnection.swift new file mode 100644 index 0000000..2892b6e --- /dev/null +++ b/NearDrop/NearbyConnection.swift @@ -0,0 +1,458 @@ +// +// NearbyConnection.swift +// NearDrop +// +// Created by Grishka on 09.04.2023. +// + +import Foundation +import Network +import CommonCrypto +import CryptoKit +import System + +import SwiftECC +import BigInt + +class NearbyConnection{ + internal static let SANE_FRAME_LENGTH=5*1024*1024 + + internal let connection:NWConnection + internal var remoteDeviceInfo:RemoteDeviceInfo? + private var payloadBuffers:[Int64:NSMutableData]=[:] + internal var encryptionDone:Bool=false + internal var transferredFiles:[Int64:InternalFileInfo]=[:] + public let id:String + internal var lastError:Error? + private var connectionClosed:Bool=false + + // UKEY2-related state + internal var publicKey:ECPublicKey? + internal var privateKey:ECPrivateKey? + internal var ukeyClientInitMsgData:Data? + internal var ukeyServerInitMsgData:Data? + + // SecureMessage encryption keys + internal var decryptKey:[UInt8]? + internal var encryptKey:[UInt8]? + internal var recvHmacKey:SymmetricKey? + internal var sendHmacKey:SymmetricKey? + + // SecureMessage sequence numbers + private var serverSeq:Int32=0 + private var clientSeq:Int32=0 + + private(set) var pinCode:String? + + init(connection:NWConnection, id:String) { + self.connection=connection + self.id=id + } + + func start(){ + connection.stateUpdateHandler={state in + if case .ready = state { + self.receiveFrameAsync() + } else if case .failed(let err) = state { + self.lastError=err + print("Error opening socket: \(err)") + self.handleConnectionClosure() + } + } + connection.start(queue: .global(qos: .utility)) + } + + internal func handleConnectionClosure(){ + print("Connection closed") + } + + internal func protocolError(){ + disconnect() + } + + internal func processReceivedFrame(frameData:Data){ + fatalError() + } + + internal func processTransferSetupFrame(_ frame:Sharing_Nearby_Frame) throws{ + fatalError() + } + + internal func isServer() -> Bool{ + fatalError() + } + + internal func processFileChunk(frame:Location_Nearby_Connections_PayloadTransferFrame) throws{ + protocolError() + } + + private func receiveFrameAsync(){ + connection.receive(minimumIncompleteLength: 4, maximumLength: 4) { content, contentContext, isComplete, error in + if self.connectionClosed{ + return + } + if isComplete{ + self.handleConnectionClosure() + return + } + if !(error==nil){ + self.lastError=error + self.protocolError() + return + } + guard let content=content else { + assertionFailure() + return + } + let frameLength:UInt32=UInt32(content[0]) << 24 | UInt32(content[1]) << 16 | UInt32(content[2]) << 8 | UInt32(content[3]) + guard frameLength> 24), + UInt8(length >> 16), + UInt8(length >> 8), + UInt8(length) + ]) + lengthPrefixedData.append(frame) + connection.send(content: lengthPrefixedData, completion: .contentProcessed({ error in + + })) + } + + internal func encryptAndSendOfflineFrame(_ frame:Location_Nearby_Connections_OfflineFrame) throws{ + var d2dMsg=Securegcm_DeviceToDeviceMessage() + serverSeq+=1 + d2dMsg.sequenceNumber=serverSeq + d2dMsg.message=try frame.serializedData() + + let serializedMsg=[UInt8](try d2dMsg.serializedData()) + let iv=Data.randomData(length: 16) + var encryptedData=Data(count: serializedMsg.count+16) + var encryptedLength:size_t=0 + encryptedData.withUnsafeMutableBytes({ + let status=CCCrypt( + CCOperation(kCCEncrypt), + CCAlgorithm(kCCAlgorithmAES128), + CCOptions(kCCOptionPKCS7Padding), + encryptKey, kCCKeySizeAES256, + [UInt8](iv), + serializedMsg, serializedMsg.count, + $0.baseAddress, $0.count, + &encryptedLength + ) + guard status==kCCSuccess else { fatalError("CCCrypt error: \(status)") } + }) + + var hb=Securemessage_HeaderAndBody() + hb.body=encryptedData.prefix(encryptedLength) + hb.header=Securemessage_Header() + hb.header.encryptionScheme = .aes256Cbc + hb.header.signatureScheme = .hmacSha256 + hb.header.iv=iv + var md=Securegcm_GcmMetadata() + md.type = .deviceToDeviceMessage + md.version=1 + hb.header.publicMetadata=try md.serializedData() + + var smsg=Securemessage_SecureMessage() + smsg.headerAndBody=try hb.serializedData() + smsg.signature=Data(HMAC.authenticationCode(for: smsg.headerAndBody, using: sendHmacKey!)) + sendFrameAsync(try smsg.serializedData()) + } + + internal func sendTransferSetupFrame(_ frame:Sharing_Nearby_Frame) throws{ + var transfer=Location_Nearby_Connections_PayloadTransferFrame() + transfer.packetType = .data + transfer.payloadChunk.offset=0 + transfer.payloadChunk.flags=0 + transfer.payloadChunk.body=try frame.serializedData() + transfer.payloadHeader.id=Int64.random(in: Int64.min...Int64.max) + transfer.payloadHeader.type = .bytes + transfer.payloadHeader.totalSize=Int64(transfer.payloadChunk.body.count) + transfer.payloadHeader.isSensitive=false + + var wrapper=Location_Nearby_Connections_OfflineFrame() + wrapper.version = .v1 + wrapper.v1=Location_Nearby_Connections_V1Frame() + wrapper.v1.type = .payloadTransfer + wrapper.v1.payloadTransfer=transfer + try encryptAndSendOfflineFrame(wrapper) + + transfer.payloadChunk.flags=1 // .lastChunk + transfer.payloadChunk.offset=Int64(transfer.payloadChunk.body.count) + transfer.payloadChunk.clearBody() + wrapper.v1.payloadTransfer=transfer + try encryptAndSendOfflineFrame(wrapper) + } + + internal func decryptAndProcessReceivedSecureMessage(_ smsg:Securemessage_SecureMessage) throws{ + guard smsg.hasSignature, smsg.hasHeaderAndBody else { throw NearbyError.requiredFieldMissing } + let hmac=Data(HMAC.authenticationCode(for: smsg.headerAndBody, using: recvHmacKey!)) + guard hmac==smsg.signature else { throw NearbyError.protocolError("hmac!=signature") } + let headerAndBody=try Securemessage_HeaderAndBody(serializedData: smsg.headerAndBody) + var decryptedData=Data(count: headerAndBody.body.count) + + var decryptedLength:Int=0 + decryptedData.withUnsafeMutableBytes({ + let status=CCCrypt( + CCOperation(kCCDecrypt), + CCAlgorithm(kCCAlgorithmAES128), + CCOptions(kCCOptionPKCS7Padding), + decryptKey, kCCKeySizeAES256, + [UInt8](headerAndBody.header.iv), + [UInt8](headerAndBody.body), headerAndBody.body.count, + $0.baseAddress, $0.count, + &decryptedLength + ) + guard status==kCCSuccess else { fatalError("CCCrypt error: \(status)") } + }) + decryptedData=decryptedData.prefix(decryptedLength) + let d2dMsg=try Securegcm_DeviceToDeviceMessage(serializedData: decryptedData) + guard d2dMsg.hasMessage, d2dMsg.hasSequenceNumber else { throw NearbyError.requiredFieldMissing } + clientSeq+=1 + guard d2dMsg.sequenceNumber==clientSeq else { throw NearbyError.protocolError("Wrong sequence number. Expected \(clientSeq), got \(d2dMsg.sequenceNumber)") } + let offlineFrame=try Location_Nearby_Connections_OfflineFrame(serializedData: d2dMsg.message) + guard offlineFrame.hasV1, offlineFrame.v1.hasType else { throw NearbyError.requiredFieldMissing } + + if case .payloadTransfer = offlineFrame.v1.type { + guard offlineFrame.v1.hasPayloadTransfer else { throw NearbyError.requiredFieldMissing } + let payloadTransfer=offlineFrame.v1.payloadTransfer + let header=payloadTransfer.payloadHeader; + let chunk=payloadTransfer.payloadChunk; + guard header.hasType, header.hasID else { throw NearbyError.requiredFieldMissing } + guard payloadTransfer.hasPayloadChunk, chunk.hasOffset, chunk.hasFlags else { throw NearbyError.requiredFieldMissing } + if case .bytes = header.type{ + let payloadID=header.id + if header.totalSize>InboundNearbyConnection.SANE_FRAME_LENGTH{ + payloadBuffers.removeValue(forKey: payloadID) + throw NearbyError.protocolError("Payload too large (\(header.totalSize) bytes)") + } + if payloadBuffers[payloadID]==nil { + payloadBuffers[payloadID]=NSMutableData(capacity: Int(header.totalSize)) + } + let buffer=payloadBuffers[payloadID]! + guard chunk.offset==buffer.count else { + payloadBuffers.removeValue(forKey: payloadID) + throw NearbyError.protocolError("Unexpected chunk offset \(chunk.offset), expected \(buffer.count)") + } + if chunk.hasBody { + buffer.append(chunk.body) + } + if (chunk.flags & 1)==1 { + payloadBuffers.removeValue(forKey: payloadID) + let innerFrame=try Sharing_Nearby_Frame(serializedData: buffer as Data) + try processTransferSetupFrame(innerFrame) + } + }else if case .file = header.type{ + try processFileChunk(frame: payloadTransfer) + } + }else if case .keepAlive = offlineFrame.v1.type{ + sendKeepAlive(ack: true) + }else{ + print("Unhandled offline frame encrypted: \(offlineFrame)") + } + } + + internal static func pinCodeFromAuthKey(_ key:SymmetricKey) -> String{ + var hash:Int=0 + var multiplier:Int=1 + let keyBytes:[UInt8]=key.withUnsafeBytes({ + return [UInt8]($0) + }) + + for _byte in keyBytes { + let byte=Int(Int8(bitPattern: _byte)) + hash=(hash+byte*multiplier)%9973 + multiplier=(multiplier*31)%9973 + } + + return String(format: "%04d", abs(hash)) + } + + internal func finalizeKeyExchange(peerKey:Securemessage_GenericPublicKey) throws{ + guard peerKey.hasEcP256PublicKey else { throw NearbyError.requiredFieldMissing } + + let domain=Domain.instance(curve: .EC256r1) + var clientX=peerKey.ecP256PublicKey.x + var clientY=peerKey.ecP256PublicKey.y + if clientX.count>32{ + clientX=clientX.suffix(32) + } + if clientY.count>32{ + clientY=clientY.suffix(32) + } + let key=try ECPublicKey(domain: domain, w: Point(BInt(magnitude: [UInt8](clientX)), BInt(magnitude: [UInt8](clientY)))) + + let dhs=(try privateKey?.domain.multiplyPoint(key.w, privateKey!.s).x.asMagnitudeBytes())! + var sha=SHA256() + sha.update(data: dhs) + let derivedSecretKey=Data(sha.finalize()) + + var ukeyInfo=Data() + ukeyInfo.append(ukeyClientInitMsgData!) + ukeyInfo.append(ukeyServerInitMsgData!) + let authString=HKDF.deriveKey(inputKeyMaterial: SymmetricKey(data: derivedSecretKey), salt: "UKEY2 v1 auth".data(using: .utf8)!, info: ukeyInfo, outputByteCount: 32) + let nextSecret=HKDF.deriveKey(inputKeyMaterial: SymmetricKey(data: derivedSecretKey), salt: "UKEY2 v1 next".data(using: .utf8)!, info: ukeyInfo, outputByteCount: 32) + + pinCode=NearbyConnection.pinCodeFromAuthKey(authString) + + let salt:Data=Data([0x82, 0xAA, 0x55, 0xA0, 0xD3, 0x97, 0xF8, 0x83, 0x46, 0xCA, 0x1C, + 0xEE, 0x8D, 0x39, 0x09, 0xB9, 0x5F, 0x13, 0xFA, 0x7D, 0xEB, 0x1D, + 0x4A, 0xB3, 0x83, 0x76, 0xB8, 0x25, 0x6D, 0xA8, 0x55, 0x10]) + + let d2dClientKey=HKDF.deriveKey(inputKeyMaterial: nextSecret, salt: salt, info: "client".data(using: .utf8)!, outputByteCount: 32) + let d2dServerKey=HKDF.deriveKey(inputKeyMaterial: nextSecret, salt: salt, info: "server".data(using: .utf8)!, outputByteCount: 32) + + sha=SHA256() + sha.update(data: "SecureMessage".data(using: .utf8)!) + let smsgSalt=Data(sha.finalize()) + + let clientKey=HKDF.deriveKey(inputKeyMaterial: d2dClientKey, salt: smsgSalt, info: "ENC:2".data(using: .utf8)!, outputByteCount: 32).withUnsafeBytes({return [UInt8]($0)}) + let clientHmacKey=HKDF.deriveKey(inputKeyMaterial: d2dClientKey, salt: smsgSalt, info: "SIG:1".data(using: .utf8)!, outputByteCount: 32) + let serverKey=HKDF.deriveKey(inputKeyMaterial: d2dServerKey, salt: smsgSalt, info: "ENC:2".data(using: .utf8)!, outputByteCount: 32).withUnsafeBytes({return [UInt8]($0)}) + let serverHmacKey=HKDF.deriveKey(inputKeyMaterial: d2dServerKey, salt: smsgSalt, info: "SIG:1".data(using: .utf8)!, outputByteCount: 32) + + if isServer(){ + decryptKey=clientKey + recvHmacKey=clientHmacKey + encryptKey=serverKey + sendHmacKey=serverHmacKey + }else{ + decryptKey=serverKey + recvHmacKey=serverHmacKey + encryptKey=clientKey + sendHmacKey=clientHmacKey + } + } + + internal func disconnect(){ + connection.send(content: nil, isComplete: true, completion: .contentProcessed({ error in + self.handleConnectionClosure() + })) + connectionClosed=true + } + + internal func sendDisconnectionAndDisconnect() throws{ + var offlineFrame=Location_Nearby_Connections_OfflineFrame() + offlineFrame.version = .v1 + offlineFrame.v1.type = .disconnection + offlineFrame.v1.disconnection=Location_Nearby_Connections_DisconnectionFrame() + + if encryptionDone{ + try encryptAndSendOfflineFrame(offlineFrame) + }else{ + sendFrameAsync(try offlineFrame.serializedData()) + } + disconnect() + } + + internal func sendUkey2Alert(type:Securegcm_Ukey2Alert.AlertType){ + var alert=Securegcm_Ukey2Alert() + alert.type=type + var msg=Securegcm_Ukey2Message() + msg.messageType = .alert + msg.messageData = try! alert.serializedData() + sendFrameAsync(try! msg.serializedData()) + disconnect() + } + + internal func sendKeepAlive(ack:Bool){ + var offlineFrame=Location_Nearby_Connections_OfflineFrame() + offlineFrame.version = .v1 + offlineFrame.v1.type = .keepAlive + offlineFrame.v1.keepAlive.ack=ack + + do{ + if encryptionDone{ + try encryptAndSendOfflineFrame(offlineFrame) + }else{ + sendFrameAsync(try offlineFrame.serializedData()) + } + }catch{ + print("Error sending KEEP_ALIVE: \(error)") + } + } +} + +enum NearbyError:Error{ + case protocolError(_ message:String) + case requiredFieldMissing + case ukey2 + case inputOutput(cause:Errno) +} + + +struct RemoteDeviceInfo{ + let name:String + let type:DeviceType + + enum DeviceType{ + case unknown + case phone + case tablet + case computer + + static func fromRawValue(value:Int) -> DeviceType{ + switch value { + case 0: + return .unknown + case 1: + return .phone + case 2: + return .tablet + case 3: + return .computer + default: + return .unknown + } + } + } +} + +struct TransferMetadata{ + let files:[FileMetadata] +} + +struct FileMetadata{ + let name:String + let size:Int64 + let mimeType:String +} + +struct InternalFileInfo{ + let meta:FileMetadata + let payloadID:Int64 + let destinationURL:URL + var bytesTransferred:Int64=0 + var fileHandle:FileHandle? + var progress:Progress? + var created:Bool=false +} diff --git a/NearDrop/NearbyConnectionManager.swift b/NearDrop/NearbyConnectionManager.swift new file mode 100644 index 0000000..aedd0d3 --- /dev/null +++ b/NearDrop/NearbyConnectionManager.swift @@ -0,0 +1,134 @@ +// +// NearbyConnectionManager.swift +// NearDrop +// +// Created by Grishka on 08.04.2023. +// + +import Foundation +import Network +import UserNotifications + +class NearbyConnectionManager : NSObject, NetServiceDelegate, InboundNearbyConnectionDelegate, UNUserNotificationCenterDelegate{ + + private var tcpListener:NWListener; + private let endpointID:[UInt8]=generateEndpointID() + private var mdnsService:NetService? + private var activeConnections:[String:InboundNearbyConnection]=[:] + + override init() { + tcpListener=try! NWListener(using: NWParameters(tls: .none)) + super.init() + UNUserNotificationCenter.current().delegate=self + startTCPListener() + } + + private func startTCPListener(){ + tcpListener.stateUpdateHandler={(state:NWListener.State) in + if case .ready = state { + self.initMDNS() + } + } + tcpListener.newConnectionHandler={(connection:NWConnection) in + let id=UUID().uuidString + let conn=InboundNearbyConnection(connection: connection, id: id) + self.activeConnections[id]=conn + conn.delegate=self + conn.start() + } + tcpListener.start(queue: .global(qos: .utility)) + } + + private static func generateEndpointID()->[UInt8]{ + var id:[UInt8]=[] + let alphabet="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".compactMap {UInt8($0.asciiValue!)} + for _ in 0...3{ + id.append(alphabet[Int.random(in: 0.. Void) { + activeConnections[response.notification.request.content.userInfo["transferID"]! as! String]?.submitUserConsent(accepted: response.actionIdentifier=="ACCEPT") + completionHandler() + } +} + diff --git a/NearDrop/Protobuf/device_to_device_messages.pb.swift b/NearDrop/Protobuf/device_to_device_messages.pb.swift new file mode 100644 index 0000000..61ccd84 --- /dev/null +++ b/NearDrop/Protobuf/device_to_device_messages.pb.swift @@ -0,0 +1,540 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: device_to_device_messages.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Type of curve +enum Securegcm_Curve: SwiftProtobuf.Enum { + typealias RawValue = Int + case ed25519 // = 1 + + init() { + self = .ed25519 + } + + init?(rawValue: Int) { + switch rawValue { + case 1: self = .ed25519 + default: return nil + } + } + + var rawValue: Int { + switch self { + case .ed25519: return 1 + } + } + +} + +#if swift(>=4.2) + +extension Securegcm_Curve: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// Used by protocols between devices +struct Securegcm_DeviceToDeviceMessage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// the payload of the message + var message: Data { + get {return _message ?? Data()} + set {_message = newValue} + } + /// Returns true if `message` has been explicitly set. + var hasMessage: Bool {return self._message != nil} + /// Clears the value of `message`. Subsequent reads from it will return its default value. + mutating func clearMessage() {self._message = nil} + + /// the sequence number of the message - must be increasing. + var sequenceNumber: Int32 { + get {return _sequenceNumber ?? 0} + set {_sequenceNumber = newValue} + } + /// Returns true if `sequenceNumber` has been explicitly set. + var hasSequenceNumber: Bool {return self._sequenceNumber != nil} + /// Clears the value of `sequenceNumber`. Subsequent reads from it will return its default value. + mutating func clearSequenceNumber() {self._sequenceNumber = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _message: Data? = nil + fileprivate var _sequenceNumber: Int32? = nil +} + +/// sent as the first message from initiator to responder +/// in an unauthenticated Diffie-Hellman Key Exchange +struct Securegcm_InitiatorHello { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The session public key to send to the responder + var publicDhKey: Securemessage_GenericPublicKey { + get {return _publicDhKey ?? Securemessage_GenericPublicKey()} + set {_publicDhKey = newValue} + } + /// Returns true if `publicDhKey` has been explicitly set. + var hasPublicDhKey: Bool {return self._publicDhKey != nil} + /// Clears the value of `publicDhKey`. Subsequent reads from it will return its default value. + mutating func clearPublicDhKey() {self._publicDhKey = nil} + + /// The protocol version + var protocolVersion: Int32 { + get {return _protocolVersion ?? 0} + set {_protocolVersion = newValue} + } + /// Returns true if `protocolVersion` has been explicitly set. + var hasProtocolVersion: Bool {return self._protocolVersion != nil} + /// Clears the value of `protocolVersion`. Subsequent reads from it will return its default value. + mutating func clearProtocolVersion() {self._protocolVersion = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _publicDhKey: Securemessage_GenericPublicKey? = nil + fileprivate var _protocolVersion: Int32? = nil +} + +/// sent inside the header of the first message from the responder to the +/// initiator in an unauthenticated Diffie-Hellman Key Exchange +struct Securegcm_ResponderHello { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The session public key to send to the initiator + var publicDhKey: Securemessage_GenericPublicKey { + get {return _publicDhKey ?? Securemessage_GenericPublicKey()} + set {_publicDhKey = newValue} + } + /// Returns true if `publicDhKey` has been explicitly set. + var hasPublicDhKey: Bool {return self._publicDhKey != nil} + /// Clears the value of `publicDhKey`. Subsequent reads from it will return its default value. + mutating func clearPublicDhKey() {self._publicDhKey = nil} + + /// The protocol version + var protocolVersion: Int32 { + get {return _protocolVersion ?? 0} + set {_protocolVersion = newValue} + } + /// Returns true if `protocolVersion` has been explicitly set. + var hasProtocolVersion: Bool {return self._protocolVersion != nil} + /// Clears the value of `protocolVersion`. Subsequent reads from it will return its default value. + mutating func clearProtocolVersion() {self._protocolVersion = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _publicDhKey: Securemessage_GenericPublicKey? = nil + fileprivate var _protocolVersion: Int32? = nil +} + +/// A convenience proto for encoding curve points in affine representation +struct Securegcm_EcPoint { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var curve: Securegcm_Curve { + get {return _curve ?? .ed25519} + set {_curve = newValue} + } + /// Returns true if `curve` has been explicitly set. + var hasCurve: Bool {return self._curve != nil} + /// Clears the value of `curve`. Subsequent reads from it will return its default value. + mutating func clearCurve() {self._curve = nil} + + /// x and y are encoded in big-endian two's complement + /// client MUST verify (x,y) is a valid point on the specified curve + var x: Data { + get {return _x ?? Data()} + set {_x = newValue} + } + /// Returns true if `x` has been explicitly set. + var hasX: Bool {return self._x != nil} + /// Clears the value of `x`. Subsequent reads from it will return its default value. + mutating func clearX() {self._x = nil} + + var y: Data { + get {return _y ?? Data()} + set {_y = newValue} + } + /// Returns true if `y` has been explicitly set. + var hasY: Bool {return self._y != nil} + /// Clears the value of `y`. Subsequent reads from it will return its default value. + mutating func clearY() {self._y = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _curve: Securegcm_Curve? = nil + fileprivate var _x: Data? = nil + fileprivate var _y: Data? = nil +} + +struct Securegcm_SpakeHandshakeMessage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Each flow in the protocol bumps this counter + var flowNumber: Int32 { + get {return _flowNumber ?? 0} + set {_flowNumber = newValue} + } + /// Returns true if `flowNumber` has been explicitly set. + var hasFlowNumber: Bool {return self._flowNumber != nil} + /// Clears the value of `flowNumber`. Subsequent reads from it will return its default value. + mutating func clearFlowNumber() {self._flowNumber = nil} + + /// Some (but not all) SPAKE flows send a point on an elliptic curve + var ecPoint: Securegcm_EcPoint { + get {return _ecPoint ?? Securegcm_EcPoint()} + set {_ecPoint = newValue} + } + /// Returns true if `ecPoint` has been explicitly set. + var hasEcPoint: Bool {return self._ecPoint != nil} + /// Clears the value of `ecPoint`. Subsequent reads from it will return its default value. + mutating func clearEcPoint() {self._ecPoint = nil} + + /// Some (but not all) SPAKE flows send a hash value + var hashValue_p: Data { + get {return _hashValue_p ?? Data()} + set {_hashValue_p = newValue} + } + /// Returns true if `hashValue_p` has been explicitly set. + var hasHashValue_p: Bool {return self._hashValue_p != nil} + /// Clears the value of `hashValue_p`. Subsequent reads from it will return its default value. + mutating func clearHashValue_p() {self._hashValue_p = nil} + + /// The last flow of a SPAKE protocol can send an optional payload, + /// since the key exchange is already complete on the sender's side. + var payload: Data { + get {return _payload ?? Data()} + set {_payload = newValue} + } + /// Returns true if `payload` has been explicitly set. + var hasPayload: Bool {return self._payload != nil} + /// Clears the value of `payload`. Subsequent reads from it will return its default value. + mutating func clearPayload() {self._payload = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _flowNumber: Int32? = nil + fileprivate var _ecPoint: Securegcm_EcPoint? = nil + fileprivate var _hashValue_p: Data? = nil + fileprivate var _payload: Data? = nil +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Securegcm_Curve: @unchecked Sendable {} +extension Securegcm_DeviceToDeviceMessage: @unchecked Sendable {} +extension Securegcm_InitiatorHello: @unchecked Sendable {} +extension Securegcm_ResponderHello: @unchecked Sendable {} +extension Securegcm_EcPoint: @unchecked Sendable {} +extension Securegcm_SpakeHandshakeMessage: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "securegcm" + +extension Securegcm_Curve: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "ED_25519"), + ] +} + +extension Securegcm_DeviceToDeviceMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".DeviceToDeviceMessage" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "message"), + 2: .standard(proto: "sequence_number"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._message) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self._sequenceNumber) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._message { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._sequenceNumber { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_DeviceToDeviceMessage, rhs: Securegcm_DeviceToDeviceMessage) -> Bool { + if lhs._message != rhs._message {return false} + if lhs._sequenceNumber != rhs._sequenceNumber {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_InitiatorHello: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".InitiatorHello" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "public_dh_key"), + 2: .standard(proto: "protocol_version"), + ] + + public var isInitialized: Bool { + if let v = self._publicDhKey, !v.isInitialized {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._publicDhKey) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self._protocolVersion) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._publicDhKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._protocolVersion { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_InitiatorHello, rhs: Securegcm_InitiatorHello) -> Bool { + if lhs._publicDhKey != rhs._publicDhKey {return false} + if lhs._protocolVersion != rhs._protocolVersion {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_ResponderHello: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ResponderHello" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "public_dh_key"), + 2: .standard(proto: "protocol_version"), + ] + + public var isInitialized: Bool { + if let v = self._publicDhKey, !v.isInitialized {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._publicDhKey) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self._protocolVersion) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._publicDhKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._protocolVersion { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_ResponderHello, rhs: Securegcm_ResponderHello) -> Bool { + if lhs._publicDhKey != rhs._publicDhKey {return false} + if lhs._protocolVersion != rhs._protocolVersion {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_EcPoint: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".EcPoint" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "curve"), + 2: .same(proto: "x"), + 3: .same(proto: "y"), + ] + + public var isInitialized: Bool { + if self._curve == nil {return false} + if self._x == nil {return false} + if self._y == nil {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._curve) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._x) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._y) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._curve { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._x { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try { if let v = self._y { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_EcPoint, rhs: Securegcm_EcPoint) -> Bool { + if lhs._curve != rhs._curve {return false} + if lhs._x != rhs._x {return false} + if lhs._y != rhs._y {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_SpakeHandshakeMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".SpakeHandshakeMessage" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "flow_number"), + 2: .standard(proto: "ec_point"), + 3: .standard(proto: "hash_value"), + 4: .same(proto: "payload"), + ] + + public var isInitialized: Bool { + if let v = self._ecPoint, !v.isInitialized {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self._flowNumber) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._ecPoint) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._hashValue_p) }() + case 4: try { try decoder.decodeSingularBytesField(value: &self._payload) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._flowNumber { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 1) + } }() + try { if let v = self._ecPoint { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try { if let v = self._hashValue_p { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try { if let v = self._payload { + try visitor.visitSingularBytesField(value: v, fieldNumber: 4) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_SpakeHandshakeMessage, rhs: Securegcm_SpakeHandshakeMessage) -> Bool { + if lhs._flowNumber != rhs._flowNumber {return false} + if lhs._ecPoint != rhs._ecPoint {return false} + if lhs._hashValue_p != rhs._hashValue_p {return false} + if lhs._payload != rhs._payload {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/NearDrop/Protobuf/offline_wire_formats.pb.swift b/NearDrop/Protobuf/offline_wire_formats.pb.swift new file mode 100644 index 0000000..7524b1c --- /dev/null +++ b/NearDrop/Protobuf/offline_wire_formats.pb.swift @@ -0,0 +1,3653 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: offline_wire_formats.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +struct Location_Nearby_Connections_OfflineFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var version: Location_Nearby_Connections_OfflineFrame.Version { + get {return _version ?? .unknownVersion} + set {_version = newValue} + } + /// Returns true if `version` has been explicitly set. + var hasVersion: Bool {return self._version != nil} + /// Clears the value of `version`. Subsequent reads from it will return its default value. + mutating func clearVersion() {self._version = nil} + + /// Right now there's only 1 version, but if there are more, exactly one of + /// the following fields will be set. + var v1: Location_Nearby_Connections_V1Frame { + get {return _v1 ?? Location_Nearby_Connections_V1Frame()} + set {_v1 = newValue} + } + /// Returns true if `v1` has been explicitly set. + var hasV1: Bool {return self._v1 != nil} + /// Clears the value of `v1`. Subsequent reads from it will return its default value. + mutating func clearV1() {self._v1 = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum Version: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownVersion // = 0 + case v1 // = 1 + + init() { + self = .unknownVersion + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownVersion + case 1: self = .v1 + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownVersion: return 0 + case .v1: return 1 + } + } + + } + + init() {} + + fileprivate var _version: Location_Nearby_Connections_OfflineFrame.Version? = nil + fileprivate var _v1: Location_Nearby_Connections_V1Frame? = nil +} + +#if swift(>=4.2) + +extension Location_Nearby_Connections_OfflineFrame.Version: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Location_Nearby_Connections_V1Frame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var type: Location_Nearby_Connections_V1Frame.FrameType { + get {return _storage._type ?? .unknownFrameType} + set {_uniqueStorage()._type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return _storage._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {_uniqueStorage()._type = nil} + + /// Exactly one of the following fields will be set. + var connectionRequest: Location_Nearby_Connections_ConnectionRequestFrame { + get {return _storage._connectionRequest ?? Location_Nearby_Connections_ConnectionRequestFrame()} + set {_uniqueStorage()._connectionRequest = newValue} + } + /// Returns true if `connectionRequest` has been explicitly set. + var hasConnectionRequest: Bool {return _storage._connectionRequest != nil} + /// Clears the value of `connectionRequest`. Subsequent reads from it will return its default value. + mutating func clearConnectionRequest() {_uniqueStorage()._connectionRequest = nil} + + var connectionResponse: Location_Nearby_Connections_ConnectionResponseFrame { + get {return _storage._connectionResponse ?? Location_Nearby_Connections_ConnectionResponseFrame()} + set {_uniqueStorage()._connectionResponse = newValue} + } + /// Returns true if `connectionResponse` has been explicitly set. + var hasConnectionResponse: Bool {return _storage._connectionResponse != nil} + /// Clears the value of `connectionResponse`. Subsequent reads from it will return its default value. + mutating func clearConnectionResponse() {_uniqueStorage()._connectionResponse = nil} + + var payloadTransfer: Location_Nearby_Connections_PayloadTransferFrame { + get {return _storage._payloadTransfer ?? Location_Nearby_Connections_PayloadTransferFrame()} + set {_uniqueStorage()._payloadTransfer = newValue} + } + /// Returns true if `payloadTransfer` has been explicitly set. + var hasPayloadTransfer: Bool {return _storage._payloadTransfer != nil} + /// Clears the value of `payloadTransfer`. Subsequent reads from it will return its default value. + mutating func clearPayloadTransfer() {_uniqueStorage()._payloadTransfer = nil} + + var bandwidthUpgradeNegotiation: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame { + get {return _storage._bandwidthUpgradeNegotiation ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame()} + set {_uniqueStorage()._bandwidthUpgradeNegotiation = newValue} + } + /// Returns true if `bandwidthUpgradeNegotiation` has been explicitly set. + var hasBandwidthUpgradeNegotiation: Bool {return _storage._bandwidthUpgradeNegotiation != nil} + /// Clears the value of `bandwidthUpgradeNegotiation`. Subsequent reads from it will return its default value. + mutating func clearBandwidthUpgradeNegotiation() {_uniqueStorage()._bandwidthUpgradeNegotiation = nil} + + var keepAlive: Location_Nearby_Connections_KeepAliveFrame { + get {return _storage._keepAlive ?? Location_Nearby_Connections_KeepAliveFrame()} + set {_uniqueStorage()._keepAlive = newValue} + } + /// Returns true if `keepAlive` has been explicitly set. + var hasKeepAlive: Bool {return _storage._keepAlive != nil} + /// Clears the value of `keepAlive`. Subsequent reads from it will return its default value. + mutating func clearKeepAlive() {_uniqueStorage()._keepAlive = nil} + + var disconnection: Location_Nearby_Connections_DisconnectionFrame { + get {return _storage._disconnection ?? Location_Nearby_Connections_DisconnectionFrame()} + set {_uniqueStorage()._disconnection = newValue} + } + /// Returns true if `disconnection` has been explicitly set. + var hasDisconnection: Bool {return _storage._disconnection != nil} + /// Clears the value of `disconnection`. Subsequent reads from it will return its default value. + mutating func clearDisconnection() {_uniqueStorage()._disconnection = nil} + + var pairedKeyEncryption: Location_Nearby_Connections_PairedKeyEncryptionFrame { + get {return _storage._pairedKeyEncryption ?? Location_Nearby_Connections_PairedKeyEncryptionFrame()} + set {_uniqueStorage()._pairedKeyEncryption = newValue} + } + /// Returns true if `pairedKeyEncryption` has been explicitly set. + var hasPairedKeyEncryption: Bool {return _storage._pairedKeyEncryption != nil} + /// Clears the value of `pairedKeyEncryption`. Subsequent reads from it will return its default value. + mutating func clearPairedKeyEncryption() {_uniqueStorage()._pairedKeyEncryption = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum FrameType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownFrameType // = 0 + case connectionRequest // = 1 + case connectionResponse // = 2 + case payloadTransfer // = 3 + case bandwidthUpgradeNegotiation // = 4 + case keepAlive // = 5 + case disconnection // = 6 + case pairedKeyEncryption // = 7 + + init() { + self = .unknownFrameType + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownFrameType + case 1: self = .connectionRequest + case 2: self = .connectionResponse + case 3: self = .payloadTransfer + case 4: self = .bandwidthUpgradeNegotiation + case 5: self = .keepAlive + case 6: self = .disconnection + case 7: self = .pairedKeyEncryption + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownFrameType: return 0 + case .connectionRequest: return 1 + case .connectionResponse: return 2 + case .payloadTransfer: return 3 + case .bandwidthUpgradeNegotiation: return 4 + case .keepAlive: return 5 + case .disconnection: return 6 + case .pairedKeyEncryption: return 7 + } + } + + } + + init() {} + + fileprivate var _storage = _StorageClass.defaultInstance +} + +#if swift(>=4.2) + +extension Location_Nearby_Connections_V1Frame.FrameType: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Location_Nearby_Connections_ConnectionRequestFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var endpointID: String { + get {return _storage._endpointID ?? String()} + set {_uniqueStorage()._endpointID = newValue} + } + /// Returns true if `endpointID` has been explicitly set. + var hasEndpointID: Bool {return _storage._endpointID != nil} + /// Clears the value of `endpointID`. Subsequent reads from it will return its default value. + mutating func clearEndpointID() {_uniqueStorage()._endpointID = nil} + + var endpointName: String { + get {return _storage._endpointName ?? String()} + set {_uniqueStorage()._endpointName = newValue} + } + /// Returns true if `endpointName` has been explicitly set. + var hasEndpointName: Bool {return _storage._endpointName != nil} + /// Clears the value of `endpointName`. Subsequent reads from it will return its default value. + mutating func clearEndpointName() {_uniqueStorage()._endpointName = nil} + + var handshakeData: Data { + get {return _storage._handshakeData ?? Data()} + set {_uniqueStorage()._handshakeData = newValue} + } + /// Returns true if `handshakeData` has been explicitly set. + var hasHandshakeData: Bool {return _storage._handshakeData != nil} + /// Clears the value of `handshakeData`. Subsequent reads from it will return its default value. + mutating func clearHandshakeData() {_uniqueStorage()._handshakeData = nil} + + /// A random number generated for each outgoing connection that is presently + /// used to act as a tiebreaker when 2 devices connect to each other + /// simultaneously; this can also be used for other initialization-scoped + /// things in the future. + var nonce: Int32 { + get {return _storage._nonce ?? 0} + set {_uniqueStorage()._nonce = newValue} + } + /// Returns true if `nonce` has been explicitly set. + var hasNonce: Bool {return _storage._nonce != nil} + /// Clears the value of `nonce`. Subsequent reads from it will return its default value. + mutating func clearNonce() {_uniqueStorage()._nonce = nil} + + /// The mediums this device supports upgrading to. This list should be filtered + /// by both the strategy and this device's individual limitations. + var mediums: [Location_Nearby_Connections_ConnectionRequestFrame.Medium] { + get {return _storage._mediums} + set {_uniqueStorage()._mediums = newValue} + } + + var endpointInfo: Data { + get {return _storage._endpointInfo ?? Data()} + set {_uniqueStorage()._endpointInfo = newValue} + } + /// Returns true if `endpointInfo` has been explicitly set. + var hasEndpointInfo: Bool {return _storage._endpointInfo != nil} + /// Clears the value of `endpointInfo`. Subsequent reads from it will return its default value. + mutating func clearEndpointInfo() {_uniqueStorage()._endpointInfo = nil} + + var mediumMetadata: Location_Nearby_Connections_MediumMetadata { + get {return _storage._mediumMetadata ?? Location_Nearby_Connections_MediumMetadata()} + set {_uniqueStorage()._mediumMetadata = newValue} + } + /// Returns true if `mediumMetadata` has been explicitly set. + var hasMediumMetadata: Bool {return _storage._mediumMetadata != nil} + /// Clears the value of `mediumMetadata`. Subsequent reads from it will return its default value. + mutating func clearMediumMetadata() {_uniqueStorage()._mediumMetadata = nil} + + var keepAliveIntervalMillis: Int32 { + get {return _storage._keepAliveIntervalMillis ?? 0} + set {_uniqueStorage()._keepAliveIntervalMillis = newValue} + } + /// Returns true if `keepAliveIntervalMillis` has been explicitly set. + var hasKeepAliveIntervalMillis: Bool {return _storage._keepAliveIntervalMillis != nil} + /// Clears the value of `keepAliveIntervalMillis`. Subsequent reads from it will return its default value. + mutating func clearKeepAliveIntervalMillis() {_uniqueStorage()._keepAliveIntervalMillis = nil} + + var keepAliveTimeoutMillis: Int32 { + get {return _storage._keepAliveTimeoutMillis ?? 0} + set {_uniqueStorage()._keepAliveTimeoutMillis = newValue} + } + /// Returns true if `keepAliveTimeoutMillis` has been explicitly set. + var hasKeepAliveTimeoutMillis: Bool {return _storage._keepAliveTimeoutMillis != nil} + /// Clears the value of `keepAliveTimeoutMillis`. Subsequent reads from it will return its default value. + mutating func clearKeepAliveTimeoutMillis() {_uniqueStorage()._keepAliveTimeoutMillis = nil} + + /// The type of {@link Device} object. + var deviceType: Int32 { + get {return _storage._deviceType ?? 0} + set {_uniqueStorage()._deviceType = newValue} + } + /// Returns true if `deviceType` has been explicitly set. + var hasDeviceType: Bool {return _storage._deviceType != nil} + /// Clears the value of `deviceType`. Subsequent reads from it will return its default value. + mutating func clearDeviceType() {_uniqueStorage()._deviceType = nil} + + /// The bytes of serialized {@link Device} object. + var deviceInfo: Data { + get {return _storage._deviceInfo ?? Data()} + set {_uniqueStorage()._deviceInfo = newValue} + } + /// Returns true if `deviceInfo` has been explicitly set. + var hasDeviceInfo: Bool {return _storage._deviceInfo != nil} + /// Clears the value of `deviceInfo`. Subsequent reads from it will return its default value. + mutating func clearDeviceInfo() {_uniqueStorage()._deviceInfo = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Should always match cs/symbol:location.nearby.proto.connections.Medium + /// LINT.IfChange + enum Medium: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownMedium // = 0 + case mdns // = 1 + case bluetooth // = 2 + case wifiHotspot // = 3 + case ble // = 4 + case wifiLan // = 5 + case wifiAware // = 6 + case nfc // = 7 + case wifiDirect // = 8 + case webRtc // = 9 + case bleL2Cap // = 10 + case usb // = 11 + + init() { + self = .unknownMedium + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownMedium + case 1: self = .mdns + case 2: self = .bluetooth + case 3: self = .wifiHotspot + case 4: self = .ble + case 5: self = .wifiLan + case 6: self = .wifiAware + case 7: self = .nfc + case 8: self = .wifiDirect + case 9: self = .webRtc + case 10: self = .bleL2Cap + case 11: self = .usb + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownMedium: return 0 + case .mdns: return 1 + case .bluetooth: return 2 + case .wifiHotspot: return 3 + case .ble: return 4 + case .wifiLan: return 5 + case .wifiAware: return 6 + case .nfc: return 7 + case .wifiDirect: return 8 + case .webRtc: return 9 + case .bleL2Cap: return 10 + case .usb: return 11 + } + } + + } + + init() {} + + fileprivate var _storage = _StorageClass.defaultInstance +} + +#if swift(>=4.2) + +extension Location_Nearby_Connections_ConnectionRequestFrame.Medium: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// This doesn't need to send back endpoint_id and endpoint_name (like +/// the ConnectionRequestFrame does) because those have already been +/// transmitted out-of-band, at the time this endpoint was discovered. +struct Location_Nearby_Connections_ConnectionResponseFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// One of: + /// + /// - ConnectionsStatusCodes.STATUS_OK + /// - ConnectionsStatusCodes.STATUS_CONNECTION_REJECTED. + var status: Int32 { + get {return _status ?? 0} + set {_status = newValue} + } + /// Returns true if `status` has been explicitly set. + var hasStatus: Bool {return self._status != nil} + /// Clears the value of `status`. Subsequent reads from it will return its default value. + mutating func clearStatus() {self._status = nil} + + var handshakeData: Data { + get {return _handshakeData ?? Data()} + set {_handshakeData = newValue} + } + /// Returns true if `handshakeData` has been explicitly set. + var hasHandshakeData: Bool {return self._handshakeData != nil} + /// Clears the value of `handshakeData`. Subsequent reads from it will return its default value. + mutating func clearHandshakeData() {self._handshakeData = nil} + + var response: Location_Nearby_Connections_ConnectionResponseFrame.ResponseStatus { + get {return _response ?? .unknownResponseStatus} + set {_response = newValue} + } + /// Returns true if `response` has been explicitly set. + var hasResponse: Bool {return self._response != nil} + /// Clears the value of `response`. Subsequent reads from it will return its default value. + mutating func clearResponse() {self._response = nil} + + var osInfo: Location_Nearby_Connections_OsInfo { + get {return _osInfo ?? Location_Nearby_Connections_OsInfo()} + set {_osInfo = newValue} + } + /// Returns true if `osInfo` has been explicitly set. + var hasOsInfo: Bool {return self._osInfo != nil} + /// Clears the value of `osInfo`. Subsequent reads from it will return its default value. + mutating func clearOsInfo() {self._osInfo = nil} + + /// A bitmask value to indicate which medium supports Multiplex transmission + /// feature. Each supporting medium could utilize one bit starting from the + /// least significant bit in this field. eq. BT utilizes the LSB bit which 0x01 + /// means bt supports multiplex while 0x00 means not. Refer to ClientProxy.java + /// for the bit usages. + var multiplexSocketBitmask: Int32 { + get {return _multiplexSocketBitmask ?? 0} + set {_multiplexSocketBitmask = newValue} + } + /// Returns true if `multiplexSocketBitmask` has been explicitly set. + var hasMultiplexSocketBitmask: Bool {return self._multiplexSocketBitmask != nil} + /// Clears the value of `multiplexSocketBitmask`. Subsequent reads from it will return its default value. + mutating func clearMultiplexSocketBitmask() {self._multiplexSocketBitmask = nil} + + var nearbyConnectionsVersion: Int32 { + get {return _nearbyConnectionsVersion ?? 0} + set {_nearbyConnectionsVersion = newValue} + } + /// Returns true if `nearbyConnectionsVersion` has been explicitly set. + var hasNearbyConnectionsVersion: Bool {return self._nearbyConnectionsVersion != nil} + /// Clears the value of `nearbyConnectionsVersion`. Subsequent reads from it will return its default value. + mutating func clearNearbyConnectionsVersion() {self._nearbyConnectionsVersion = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Used to replace the status integer parameter with a meaningful enum item. + /// Map ConnectionsStatusCodes.STATUS_OK to ACCEPT and + /// ConnectionsStatusCodes.STATUS_CONNECTION_REJECTED to REJECT. + /// Flag: connection_replace_status_with_response_connectionResponseFrame + enum ResponseStatus: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownResponseStatus // = 0 + case accept // = 1 + case reject // = 2 + + init() { + self = .unknownResponseStatus + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownResponseStatus + case 1: self = .accept + case 2: self = .reject + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownResponseStatus: return 0 + case .accept: return 1 + case .reject: return 2 + } + } + + } + + init() {} + + fileprivate var _status: Int32? = nil + fileprivate var _handshakeData: Data? = nil + fileprivate var _response: Location_Nearby_Connections_ConnectionResponseFrame.ResponseStatus? = nil + fileprivate var _osInfo: Location_Nearby_Connections_OsInfo? = nil + fileprivate var _multiplexSocketBitmask: Int32? = nil + fileprivate var _nearbyConnectionsVersion: Int32? = nil +} + +#if swift(>=4.2) + +extension Location_Nearby_Connections_ConnectionResponseFrame.ResponseStatus: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Location_Nearby_Connections_PayloadTransferFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var packetType: Location_Nearby_Connections_PayloadTransferFrame.PacketType { + get {return _packetType ?? .unknownPacketType} + set {_packetType = newValue} + } + /// Returns true if `packetType` has been explicitly set. + var hasPacketType: Bool {return self._packetType != nil} + /// Clears the value of `packetType`. Subsequent reads from it will return its default value. + mutating func clearPacketType() {self._packetType = nil} + + var payloadHeader: Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader { + get {return _payloadHeader ?? Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader()} + set {_payloadHeader = newValue} + } + /// Returns true if `payloadHeader` has been explicitly set. + var hasPayloadHeader: Bool {return self._payloadHeader != nil} + /// Clears the value of `payloadHeader`. Subsequent reads from it will return its default value. + mutating func clearPayloadHeader() {self._payloadHeader = nil} + + /// Exactly one of the following fields will be set, depending on the type. + var payloadChunk: Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk { + get {return _payloadChunk ?? Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk()} + set {_payloadChunk = newValue} + } + /// Returns true if `payloadChunk` has been explicitly set. + var hasPayloadChunk: Bool {return self._payloadChunk != nil} + /// Clears the value of `payloadChunk`. Subsequent reads from it will return its default value. + mutating func clearPayloadChunk() {self._payloadChunk = nil} + + var controlMessage: Location_Nearby_Connections_PayloadTransferFrame.ControlMessage { + get {return _controlMessage ?? Location_Nearby_Connections_PayloadTransferFrame.ControlMessage()} + set {_controlMessage = newValue} + } + /// Returns true if `controlMessage` has been explicitly set. + var hasControlMessage: Bool {return self._controlMessage != nil} + /// Clears the value of `controlMessage`. Subsequent reads from it will return its default value. + mutating func clearControlMessage() {self._controlMessage = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum PacketType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownPacketType // = 0 + case data // = 1 + case control // = 2 + + init() { + self = .unknownPacketType + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownPacketType + case 1: self = .data + case 2: self = .control + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownPacketType: return 0 + case .data: return 1 + case .control: return 2 + } + } + + } + + struct PayloadHeader { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var id: Int64 { + get {return _id ?? 0} + set {_id = newValue} + } + /// Returns true if `id` has been explicitly set. + var hasID: Bool {return self._id != nil} + /// Clears the value of `id`. Subsequent reads from it will return its default value. + mutating func clearID() {self._id = nil} + + var type: Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader.PayloadType { + get {return _type ?? .unknownPayloadType} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + + var totalSize: Int64 { + get {return _totalSize ?? 0} + set {_totalSize = newValue} + } + /// Returns true if `totalSize` has been explicitly set. + var hasTotalSize: Bool {return self._totalSize != nil} + /// Clears the value of `totalSize`. Subsequent reads from it will return its default value. + mutating func clearTotalSize() {self._totalSize = nil} + + var isSensitive: Bool { + get {return _isSensitive ?? false} + set {_isSensitive = newValue} + } + /// Returns true if `isSensitive` has been explicitly set. + var hasIsSensitive: Bool {return self._isSensitive != nil} + /// Clears the value of `isSensitive`. Subsequent reads from it will return its default value. + mutating func clearIsSensitive() {self._isSensitive = nil} + + var fileName: String { + get {return _fileName ?? String()} + set {_fileName = newValue} + } + /// Returns true if `fileName` has been explicitly set. + var hasFileName: Bool {return self._fileName != nil} + /// Clears the value of `fileName`. Subsequent reads from it will return its default value. + mutating func clearFileName() {self._fileName = nil} + + var parentFolder: String { + get {return _parentFolder ?? String()} + set {_parentFolder = newValue} + } + /// Returns true if `parentFolder` has been explicitly set. + var hasParentFolder: Bool {return self._parentFolder != nil} + /// Clears the value of `parentFolder`. Subsequent reads from it will return its default value. + mutating func clearParentFolder() {self._parentFolder = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum PayloadType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownPayloadType // = 0 + case bytes // = 1 + case file // = 2 + case stream // = 3 + + init() { + self = .unknownPayloadType + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownPayloadType + case 1: self = .bytes + case 2: self = .file + case 3: self = .stream + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownPayloadType: return 0 + case .bytes: return 1 + case .file: return 2 + case .stream: return 3 + } + } + + } + + init() {} + + fileprivate var _id: Int64? = nil + fileprivate var _type: Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader.PayloadType? = nil + fileprivate var _totalSize: Int64? = nil + fileprivate var _isSensitive: Bool? = nil + fileprivate var _fileName: String? = nil + fileprivate var _parentFolder: String? = nil + } + + /// Accompanies DATA packets. + struct PayloadChunk { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var flags: Int32 { + get {return _flags ?? 0} + set {_flags = newValue} + } + /// Returns true if `flags` has been explicitly set. + var hasFlags: Bool {return self._flags != nil} + /// Clears the value of `flags`. Subsequent reads from it will return its default value. + mutating func clearFlags() {self._flags = nil} + + var offset: Int64 { + get {return _offset ?? 0} + set {_offset = newValue} + } + /// Returns true if `offset` has been explicitly set. + var hasOffset: Bool {return self._offset != nil} + /// Clears the value of `offset`. Subsequent reads from it will return its default value. + mutating func clearOffset() {self._offset = nil} + + var body: Data { + get {return _body ?? Data()} + set {_body = newValue} + } + /// Returns true if `body` has been explicitly set. + var hasBody: Bool {return self._body != nil} + /// Clears the value of `body`. Subsequent reads from it will return its default value. + mutating func clearBody() {self._body = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum Flags: SwiftProtobuf.Enum { + typealias RawValue = Int + case lastChunk // = 1 + + init() { + self = .lastChunk + } + + init?(rawValue: Int) { + switch rawValue { + case 1: self = .lastChunk + default: return nil + } + } + + var rawValue: Int { + switch self { + case .lastChunk: return 1 + } + } + + } + + init() {} + + fileprivate var _flags: Int32? = nil + fileprivate var _offset: Int64? = nil + fileprivate var _body: Data? = nil + } + + /// Accompanies CONTROL packets. + struct ControlMessage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var event: Location_Nearby_Connections_PayloadTransferFrame.ControlMessage.EventType { + get {return _event ?? .unknownEventType} + set {_event = newValue} + } + /// Returns true if `event` has been explicitly set. + var hasEvent: Bool {return self._event != nil} + /// Clears the value of `event`. Subsequent reads from it will return its default value. + mutating func clearEvent() {self._event = nil} + + var offset: Int64 { + get {return _offset ?? 0} + set {_offset = newValue} + } + /// Returns true if `offset` has been explicitly set. + var hasOffset: Bool {return self._offset != nil} + /// Clears the value of `offset`. Subsequent reads from it will return its default value. + mutating func clearOffset() {self._offset = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum EventType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownEventType // = 0 + case payloadError // = 1 + case payloadCanceled // = 2 + case payloadReceivedAck // = 3 + + init() { + self = .unknownEventType + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownEventType + case 1: self = .payloadError + case 2: self = .payloadCanceled + case 3: self = .payloadReceivedAck + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownEventType: return 0 + case .payloadError: return 1 + case .payloadCanceled: return 2 + case .payloadReceivedAck: return 3 + } + } + + } + + init() {} + + fileprivate var _event: Location_Nearby_Connections_PayloadTransferFrame.ControlMessage.EventType? = nil + fileprivate var _offset: Int64? = nil + } + + init() {} + + fileprivate var _packetType: Location_Nearby_Connections_PayloadTransferFrame.PacketType? = nil + fileprivate var _payloadHeader: Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader? = nil + fileprivate var _payloadChunk: Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk? = nil + fileprivate var _controlMessage: Location_Nearby_Connections_PayloadTransferFrame.ControlMessage? = nil +} + +#if swift(>=4.2) + +extension Location_Nearby_Connections_PayloadTransferFrame.PacketType: CaseIterable { + // Support synthesized by the compiler. +} + +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader.PayloadType: CaseIterable { + // Support synthesized by the compiler. +} + +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk.Flags: CaseIterable { + // Support synthesized by the compiler. +} + +extension Location_Nearby_Connections_PayloadTransferFrame.ControlMessage.EventType: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var eventType: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.EventType { + get {return _eventType ?? .unknownEventType} + set {_eventType = newValue} + } + /// Returns true if `eventType` has been explicitly set. + var hasEventType: Bool {return self._eventType != nil} + /// Clears the value of `eventType`. Subsequent reads from it will return its default value. + mutating func clearEventType() {self._eventType = nil} + + /// Exactly one of the following fields will be set. + var upgradePathInfo: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo { + get {return _upgradePathInfo ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo()} + set {_upgradePathInfo = newValue} + } + /// Returns true if `upgradePathInfo` has been explicitly set. + var hasUpgradePathInfo: Bool {return self._upgradePathInfo != nil} + /// Clears the value of `upgradePathInfo`. Subsequent reads from it will return its default value. + mutating func clearUpgradePathInfo() {self._upgradePathInfo = nil} + + var clientIntroduction: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroduction { + get {return _clientIntroduction ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroduction()} + set {_clientIntroduction = newValue} + } + /// Returns true if `clientIntroduction` has been explicitly set. + var hasClientIntroduction: Bool {return self._clientIntroduction != nil} + /// Clears the value of `clientIntroduction`. Subsequent reads from it will return its default value. + mutating func clearClientIntroduction() {self._clientIntroduction = nil} + + var clientIntroductionAck: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroductionAck { + get {return _clientIntroductionAck ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroductionAck()} + set {_clientIntroductionAck = newValue} + } + /// Returns true if `clientIntroductionAck` has been explicitly set. + var hasClientIntroductionAck: Bool {return self._clientIntroductionAck != nil} + /// Clears the value of `clientIntroductionAck`. Subsequent reads from it will return its default value. + mutating func clearClientIntroductionAck() {self._clientIntroductionAck = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum EventType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownEventType // = 0 + case upgradePathAvailable // = 1 + case lastWriteToPriorChannel // = 2 + case safeToClosePriorChannel // = 3 + case clientIntroduction // = 4 + case upgradeFailure // = 5 + case clientIntroductionAck // = 6 + + init() { + self = .unknownEventType + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownEventType + case 1: self = .upgradePathAvailable + case 2: self = .lastWriteToPriorChannel + case 3: self = .safeToClosePriorChannel + case 4: self = .clientIntroduction + case 5: self = .upgradeFailure + case 6: self = .clientIntroductionAck + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownEventType: return 0 + case .upgradePathAvailable: return 1 + case .lastWriteToPriorChannel: return 2 + case .safeToClosePriorChannel: return 3 + case .clientIntroduction: return 4 + case .upgradeFailure: return 5 + case .clientIntroductionAck: return 6 + } + } + + } + + /// Accompanies UPGRADE_PATH_AVAILABLE and UPGRADE_FAILURE events. + struct UpgradePathInfo { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var medium: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.Medium { + get {return _storage._medium ?? .unknownMedium} + set {_uniqueStorage()._medium = newValue} + } + /// Returns true if `medium` has been explicitly set. + var hasMedium: Bool {return _storage._medium != nil} + /// Clears the value of `medium`. Subsequent reads from it will return its default value. + mutating func clearMedium() {_uniqueStorage()._medium = nil} + + /// Exactly one of the following fields will be set. + var wifiHotspotCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiHotspotCredentials { + get {return _storage._wifiHotspotCredentials ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiHotspotCredentials()} + set {_uniqueStorage()._wifiHotspotCredentials = newValue} + } + /// Returns true if `wifiHotspotCredentials` has been explicitly set. + var hasWifiHotspotCredentials: Bool {return _storage._wifiHotspotCredentials != nil} + /// Clears the value of `wifiHotspotCredentials`. Subsequent reads from it will return its default value. + mutating func clearWifiHotspotCredentials() {_uniqueStorage()._wifiHotspotCredentials = nil} + + var wifiLanSocket: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiLanSocket { + get {return _storage._wifiLanSocket ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiLanSocket()} + set {_uniqueStorage()._wifiLanSocket = newValue} + } + /// Returns true if `wifiLanSocket` has been explicitly set. + var hasWifiLanSocket: Bool {return _storage._wifiLanSocket != nil} + /// Clears the value of `wifiLanSocket`. Subsequent reads from it will return its default value. + mutating func clearWifiLanSocket() {_uniqueStorage()._wifiLanSocket = nil} + + var bluetoothCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.BluetoothCredentials { + get {return _storage._bluetoothCredentials ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.BluetoothCredentials()} + set {_uniqueStorage()._bluetoothCredentials = newValue} + } + /// Returns true if `bluetoothCredentials` has been explicitly set. + var hasBluetoothCredentials: Bool {return _storage._bluetoothCredentials != nil} + /// Clears the value of `bluetoothCredentials`. Subsequent reads from it will return its default value. + mutating func clearBluetoothCredentials() {_uniqueStorage()._bluetoothCredentials = nil} + + var wifiAwareCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiAwareCredentials { + get {return _storage._wifiAwareCredentials ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiAwareCredentials()} + set {_uniqueStorage()._wifiAwareCredentials = newValue} + } + /// Returns true if `wifiAwareCredentials` has been explicitly set. + var hasWifiAwareCredentials: Bool {return _storage._wifiAwareCredentials != nil} + /// Clears the value of `wifiAwareCredentials`. Subsequent reads from it will return its default value. + mutating func clearWifiAwareCredentials() {_uniqueStorage()._wifiAwareCredentials = nil} + + var wifiDirectCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials { + get {return _storage._wifiDirectCredentials ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials()} + set {_uniqueStorage()._wifiDirectCredentials = newValue} + } + /// Returns true if `wifiDirectCredentials` has been explicitly set. + var hasWifiDirectCredentials: Bool {return _storage._wifiDirectCredentials != nil} + /// Clears the value of `wifiDirectCredentials`. Subsequent reads from it will return its default value. + mutating func clearWifiDirectCredentials() {_uniqueStorage()._wifiDirectCredentials = nil} + + var webRtcCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WebRtcCredentials { + get {return _storage._webRtcCredentials ?? Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WebRtcCredentials()} + set {_uniqueStorage()._webRtcCredentials = newValue} + } + /// Returns true if `webRtcCredentials` has been explicitly set. + var hasWebRtcCredentials: Bool {return _storage._webRtcCredentials != nil} + /// Clears the value of `webRtcCredentials`. Subsequent reads from it will return its default value. + mutating func clearWebRtcCredentials() {_uniqueStorage()._webRtcCredentials = nil} + + /// Disable Encryption for this upgrade medium to improve throughput. + var supportsDisablingEncryption: Bool { + get {return _storage._supportsDisablingEncryption ?? false} + set {_uniqueStorage()._supportsDisablingEncryption = newValue} + } + /// Returns true if `supportsDisablingEncryption` has been explicitly set. + var hasSupportsDisablingEncryption: Bool {return _storage._supportsDisablingEncryption != nil} + /// Clears the value of `supportsDisablingEncryption`. Subsequent reads from it will return its default value. + mutating func clearSupportsDisablingEncryption() {_uniqueStorage()._supportsDisablingEncryption = nil} + + /// An ack will be sent after the CLIENT_INTRODUCTION frame. + var supportsClientIntroductionAck: Bool { + get {return _storage._supportsClientIntroductionAck ?? false} + set {_uniqueStorage()._supportsClientIntroductionAck = newValue} + } + /// Returns true if `supportsClientIntroductionAck` has been explicitly set. + var hasSupportsClientIntroductionAck: Bool {return _storage._supportsClientIntroductionAck != nil} + /// Clears the value of `supportsClientIntroductionAck`. Subsequent reads from it will return its default value. + mutating func clearSupportsClientIntroductionAck() {_uniqueStorage()._supportsClientIntroductionAck = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + /// Should always match cs/symbol:location.nearby.proto.connections.Medium + enum Medium: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownMedium // = 0 + case mdns // = 1 + case bluetooth // = 2 + case wifiHotspot // = 3 + case ble // = 4 + case wifiLan // = 5 + case wifiAware // = 6 + case nfc // = 7 + case wifiDirect // = 8 + case webRtc // = 9 + + /// 10 is reserved. + case usb // = 11 + + init() { + self = .unknownMedium + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownMedium + case 1: self = .mdns + case 2: self = .bluetooth + case 3: self = .wifiHotspot + case 4: self = .ble + case 5: self = .wifiLan + case 6: self = .wifiAware + case 7: self = .nfc + case 8: self = .wifiDirect + case 9: self = .webRtc + case 11: self = .usb + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownMedium: return 0 + case .mdns: return 1 + case .bluetooth: return 2 + case .wifiHotspot: return 3 + case .ble: return 4 + case .wifiLan: return 5 + case .wifiAware: return 6 + case .nfc: return 7 + case .wifiDirect: return 8 + case .webRtc: return 9 + case .usb: return 11 + } + } + + } + + /// Accompanies Medium.WIFI_HOTSPOT. + struct WifiHotspotCredentials { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var ssid: String { + get {return _ssid ?? String()} + set {_ssid = newValue} + } + /// Returns true if `ssid` has been explicitly set. + var hasSsid: Bool {return self._ssid != nil} + /// Clears the value of `ssid`. Subsequent reads from it will return its default value. + mutating func clearSsid() {self._ssid = nil} + + var password: String { + get {return _password ?? String()} + set {_password = newValue} + } + /// Returns true if `password` has been explicitly set. + var hasPassword: Bool {return self._password != nil} + /// Clears the value of `password`. Subsequent reads from it will return its default value. + mutating func clearPassword() {self._password = nil} + + var port: Int32 { + get {return _port ?? 0} + set {_port = newValue} + } + /// Returns true if `port` has been explicitly set. + var hasPort: Bool {return self._port != nil} + /// Clears the value of `port`. Subsequent reads from it will return its default value. + mutating func clearPort() {self._port = nil} + + var gateway: String { + get {return _gateway ?? "0.0.0.0"} + set {_gateway = newValue} + } + /// Returns true if `gateway` has been explicitly set. + var hasGateway: Bool {return self._gateway != nil} + /// Clears the value of `gateway`. Subsequent reads from it will return its default value. + mutating func clearGateway() {self._gateway = nil} + + /// This field can be a band or frequency + var frequency: Int32 { + get {return _frequency ?? -1} + set {_frequency = newValue} + } + /// Returns true if `frequency` has been explicitly set. + var hasFrequency: Bool {return self._frequency != nil} + /// Clears the value of `frequency`. Subsequent reads from it will return its default value. + mutating func clearFrequency() {self._frequency = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _ssid: String? = nil + fileprivate var _password: String? = nil + fileprivate var _port: Int32? = nil + fileprivate var _gateway: String? = nil + fileprivate var _frequency: Int32? = nil + } + + /// Accompanies Medium.WIFI_LAN. + struct WifiLanSocket { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var ipAddress: Data { + get {return _ipAddress ?? Data()} + set {_ipAddress = newValue} + } + /// Returns true if `ipAddress` has been explicitly set. + var hasIpAddress: Bool {return self._ipAddress != nil} + /// Clears the value of `ipAddress`. Subsequent reads from it will return its default value. + mutating func clearIpAddress() {self._ipAddress = nil} + + var wifiPort: Int32 { + get {return _wifiPort ?? 0} + set {_wifiPort = newValue} + } + /// Returns true if `wifiPort` has been explicitly set. + var hasWifiPort: Bool {return self._wifiPort != nil} + /// Clears the value of `wifiPort`. Subsequent reads from it will return its default value. + mutating func clearWifiPort() {self._wifiPort = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _ipAddress: Data? = nil + fileprivate var _wifiPort: Int32? = nil + } + + /// Accompanies Medium.BLUETOOTH. + struct BluetoothCredentials { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var serviceName: String { + get {return _serviceName ?? String()} + set {_serviceName = newValue} + } + /// Returns true if `serviceName` has been explicitly set. + var hasServiceName: Bool {return self._serviceName != nil} + /// Clears the value of `serviceName`. Subsequent reads from it will return its default value. + mutating func clearServiceName() {self._serviceName = nil} + + var macAddress: String { + get {return _macAddress ?? String()} + set {_macAddress = newValue} + } + /// Returns true if `macAddress` has been explicitly set. + var hasMacAddress: Bool {return self._macAddress != nil} + /// Clears the value of `macAddress`. Subsequent reads from it will return its default value. + mutating func clearMacAddress() {self._macAddress = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _serviceName: String? = nil + fileprivate var _macAddress: String? = nil + } + + /// Accompanies Medium.WIFI_AWARE. + struct WifiAwareCredentials { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var serviceID: String { + get {return _serviceID ?? String()} + set {_serviceID = newValue} + } + /// Returns true if `serviceID` has been explicitly set. + var hasServiceID: Bool {return self._serviceID != nil} + /// Clears the value of `serviceID`. Subsequent reads from it will return its default value. + mutating func clearServiceID() {self._serviceID = nil} + + var serviceInfo: Data { + get {return _serviceInfo ?? Data()} + set {_serviceInfo = newValue} + } + /// Returns true if `serviceInfo` has been explicitly set. + var hasServiceInfo: Bool {return self._serviceInfo != nil} + /// Clears the value of `serviceInfo`. Subsequent reads from it will return its default value. + mutating func clearServiceInfo() {self._serviceInfo = nil} + + var password: String { + get {return _password ?? String()} + set {_password = newValue} + } + /// Returns true if `password` has been explicitly set. + var hasPassword: Bool {return self._password != nil} + /// Clears the value of `password`. Subsequent reads from it will return its default value. + mutating func clearPassword() {self._password = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _serviceID: String? = nil + fileprivate var _serviceInfo: Data? = nil + fileprivate var _password: String? = nil + } + + /// Accompanies Medium.WIFI_DIRECT. + struct WifiDirectCredentials { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var ssid: String { + get {return _ssid ?? String()} + set {_ssid = newValue} + } + /// Returns true if `ssid` has been explicitly set. + var hasSsid: Bool {return self._ssid != nil} + /// Clears the value of `ssid`. Subsequent reads from it will return its default value. + mutating func clearSsid() {self._ssid = nil} + + var password: String { + get {return _password ?? String()} + set {_password = newValue} + } + /// Returns true if `password` has been explicitly set. + var hasPassword: Bool {return self._password != nil} + /// Clears the value of `password`. Subsequent reads from it will return its default value. + mutating func clearPassword() {self._password = nil} + + var port: Int32 { + get {return _port ?? 0} + set {_port = newValue} + } + /// Returns true if `port` has been explicitly set. + var hasPort: Bool {return self._port != nil} + /// Clears the value of `port`. Subsequent reads from it will return its default value. + mutating func clearPort() {self._port = nil} + + var frequency: Int32 { + get {return _frequency ?? 0} + set {_frequency = newValue} + } + /// Returns true if `frequency` has been explicitly set. + var hasFrequency: Bool {return self._frequency != nil} + /// Clears the value of `frequency`. Subsequent reads from it will return its default value. + mutating func clearFrequency() {self._frequency = nil} + + var gateway: String { + get {return _gateway ?? "0.0.0.0"} + set {_gateway = newValue} + } + /// Returns true if `gateway` has been explicitly set. + var hasGateway: Bool {return self._gateway != nil} + /// Clears the value of `gateway`. Subsequent reads from it will return its default value. + mutating func clearGateway() {self._gateway = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _ssid: String? = nil + fileprivate var _password: String? = nil + fileprivate var _port: Int32? = nil + fileprivate var _frequency: Int32? = nil + fileprivate var _gateway: String? = nil + } + + /// Accompanies Medium.WEB_RTC + struct WebRtcCredentials { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var peerID: String { + get {return _peerID ?? String()} + set {_peerID = newValue} + } + /// Returns true if `peerID` has been explicitly set. + var hasPeerID: Bool {return self._peerID != nil} + /// Clears the value of `peerID`. Subsequent reads from it will return its default value. + mutating func clearPeerID() {self._peerID = nil} + + var locationHint: Location_Nearby_Connections_LocationHint { + get {return _locationHint ?? Location_Nearby_Connections_LocationHint()} + set {_locationHint = newValue} + } + /// Returns true if `locationHint` has been explicitly set. + var hasLocationHint: Bool {return self._locationHint != nil} + /// Clears the value of `locationHint`. Subsequent reads from it will return its default value. + mutating func clearLocationHint() {self._locationHint = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _peerID: String? = nil + fileprivate var _locationHint: Location_Nearby_Connections_LocationHint? = nil + } + + init() {} + + fileprivate var _storage = _StorageClass.defaultInstance + } + + /// Accompanies CLIENT_INTRODUCTION events. + struct ClientIntroduction { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var endpointID: String { + get {return _endpointID ?? String()} + set {_endpointID = newValue} + } + /// Returns true if `endpointID` has been explicitly set. + var hasEndpointID: Bool {return self._endpointID != nil} + /// Clears the value of `endpointID`. Subsequent reads from it will return its default value. + mutating func clearEndpointID() {self._endpointID = nil} + + var supportsDisablingEncryption: Bool { + get {return _supportsDisablingEncryption ?? false} + set {_supportsDisablingEncryption = newValue} + } + /// Returns true if `supportsDisablingEncryption` has been explicitly set. + var hasSupportsDisablingEncryption: Bool {return self._supportsDisablingEncryption != nil} + /// Clears the value of `supportsDisablingEncryption`. Subsequent reads from it will return its default value. + mutating func clearSupportsDisablingEncryption() {self._supportsDisablingEncryption = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _endpointID: String? = nil + fileprivate var _supportsDisablingEncryption: Bool? = nil + } + + /// Accompanies CLIENT_INTRODUCTION_ACK events. + struct ClientIntroductionAck { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + } + + init() {} + + fileprivate var _eventType: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.EventType? = nil + fileprivate var _upgradePathInfo: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo? = nil + fileprivate var _clientIntroduction: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroduction? = nil + fileprivate var _clientIntroductionAck: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroductionAck? = nil +} + +#if swift(>=4.2) + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.EventType: CaseIterable { + // Support synthesized by the compiler. +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.Medium: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Location_Nearby_Connections_KeepAliveFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// And ack will be sent after receiving KEEP_ALIVE frame. + var ack: Bool { + get {return _ack ?? false} + set {_ack = newValue} + } + /// Returns true if `ack` has been explicitly set. + var hasAck: Bool {return self._ack != nil} + /// Clears the value of `ack`. Subsequent reads from it will return its default value. + mutating func clearAck() {self._ack = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _ack: Bool? = nil +} + +/// Informs the remote side to immediately severe the socket connection. +/// Used in bandwidth upgrades to get around a race condition, but may be used +/// in other situations to trigger a faster disconnection event than waiting for +/// socket closed on the remote side. +struct Location_Nearby_Connections_DisconnectionFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Apply safe-to-disconnect protocol if true. + var requestSafeToDisconnect: Bool { + get {return _requestSafeToDisconnect ?? false} + set {_requestSafeToDisconnect = newValue} + } + /// Returns true if `requestSafeToDisconnect` has been explicitly set. + var hasRequestSafeToDisconnect: Bool {return self._requestSafeToDisconnect != nil} + /// Clears the value of `requestSafeToDisconnect`. Subsequent reads from it will return its default value. + mutating func clearRequestSafeToDisconnect() {self._requestSafeToDisconnect = nil} + + /// Ack of receiving Disconnection frame will be sent to the sender + /// frame. + var ackSafeToDisconnect: Bool { + get {return _ackSafeToDisconnect ?? false} + set {_ackSafeToDisconnect = newValue} + } + /// Returns true if `ackSafeToDisconnect` has been explicitly set. + var hasAckSafeToDisconnect: Bool {return self._ackSafeToDisconnect != nil} + /// Clears the value of `ackSafeToDisconnect`. Subsequent reads from it will return its default value. + mutating func clearAckSafeToDisconnect() {self._ackSafeToDisconnect = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _requestSafeToDisconnect: Bool? = nil + fileprivate var _ackSafeToDisconnect: Bool? = nil +} + +/// A paired key encryption packet sent between devices, contains signed data. +struct Location_Nearby_Connections_PairedKeyEncryptionFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The encrypted data (raw authentication token for the established + /// connection) in byte array format. + var signedData: Data { + get {return _signedData ?? Data()} + set {_signedData = newValue} + } + /// Returns true if `signedData` has been explicitly set. + var hasSignedData: Bool {return self._signedData != nil} + /// Clears the value of `signedData`. Subsequent reads from it will return its default value. + mutating func clearSignedData() {self._signedData = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _signedData: Data? = nil +} + +struct Location_Nearby_Connections_MediumMetadata { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// True if local device supports 5GHz. + var supports5Ghz: Bool { + get {return _supports5Ghz ?? false} + set {_supports5Ghz = newValue} + } + /// Returns true if `supports5Ghz` has been explicitly set. + var hasSupports5Ghz: Bool {return self._supports5Ghz != nil} + /// Clears the value of `supports5Ghz`. Subsequent reads from it will return its default value. + mutating func clearSupports5Ghz() {self._supports5Ghz = nil} + + /// WiFi LAN BSSID, in the form of a six-byte MAC address: XX:XX:XX:XX:XX:XX + var bssid: String { + get {return _bssid ?? String()} + set {_bssid = newValue} + } + /// Returns true if `bssid` has been explicitly set. + var hasBssid: Bool {return self._bssid != nil} + /// Clears the value of `bssid`. Subsequent reads from it will return its default value. + mutating func clearBssid() {self._bssid = nil} + + /// IP address, in network byte order: the highest order byte of the address is + /// in byte[0]. + var ipAddress: Data { + get {return _ipAddress ?? Data()} + set {_ipAddress = newValue} + } + /// Returns true if `ipAddress` has been explicitly set. + var hasIpAddress: Bool {return self._ipAddress != nil} + /// Clears the value of `ipAddress`. Subsequent reads from it will return its default value. + mutating func clearIpAddress() {self._ipAddress = nil} + + /// True if local device supports 6GHz. + var supports6Ghz: Bool { + get {return _supports6Ghz ?? false} + set {_supports6Ghz = newValue} + } + /// Returns true if `supports6Ghz` has been explicitly set. + var hasSupports6Ghz: Bool {return self._supports6Ghz != nil} + /// Clears the value of `supports6Ghz`. Subsequent reads from it will return its default value. + mutating func clearSupports6Ghz() {self._supports6Ghz = nil} + + /// True if local device has mobile radio. + var mobileRadio: Bool { + get {return _mobileRadio ?? false} + set {_mobileRadio = newValue} + } + /// Returns true if `mobileRadio` has been explicitly set. + var hasMobileRadio: Bool {return self._mobileRadio != nil} + /// Clears the value of `mobileRadio`. Subsequent reads from it will return its default value. + mutating func clearMobileRadio() {self._mobileRadio = nil} + + /// The frequency of the WiFi LAN AP(in MHz). Or -1 is not associated with an + /// AP over WiFi, -2 represents the active network uses an Ethernet transport. + var apFrequency: Int32 { + get {return _apFrequency ?? -1} + set {_apFrequency = newValue} + } + /// Returns true if `apFrequency` has been explicitly set. + var hasApFrequency: Bool {return self._apFrequency != nil} + /// Clears the value of `apFrequency`. Subsequent reads from it will return its default value. + mutating func clearApFrequency() {self._apFrequency = nil} + + /// Available channels on the local device. + var availableChannels: Location_Nearby_Connections_AvailableChannels { + get {return _availableChannels ?? Location_Nearby_Connections_AvailableChannels()} + set {_availableChannels = newValue} + } + /// Returns true if `availableChannels` has been explicitly set. + var hasAvailableChannels: Bool {return self._availableChannels != nil} + /// Clears the value of `availableChannels`. Subsequent reads from it will return its default value. + mutating func clearAvailableChannels() {self._availableChannels = nil} + + /// Usable WiFi Direct client channels on the local device. + var wifiDirectCliUsableChannels: Location_Nearby_Connections_WifiDirectCliUsableChannels { + get {return _wifiDirectCliUsableChannels ?? Location_Nearby_Connections_WifiDirectCliUsableChannels()} + set {_wifiDirectCliUsableChannels = newValue} + } + /// Returns true if `wifiDirectCliUsableChannels` has been explicitly set. + var hasWifiDirectCliUsableChannels: Bool {return self._wifiDirectCliUsableChannels != nil} + /// Clears the value of `wifiDirectCliUsableChannels`. Subsequent reads from it will return its default value. + mutating func clearWifiDirectCliUsableChannels() {self._wifiDirectCliUsableChannels = nil} + + /// Usable WiFi LAN channels on the local device. + var wifiLanUsableChannels: Location_Nearby_Connections_WifiLanUsableChannels { + get {return _wifiLanUsableChannels ?? Location_Nearby_Connections_WifiLanUsableChannels()} + set {_wifiLanUsableChannels = newValue} + } + /// Returns true if `wifiLanUsableChannels` has been explicitly set. + var hasWifiLanUsableChannels: Bool {return self._wifiLanUsableChannels != nil} + /// Clears the value of `wifiLanUsableChannels`. Subsequent reads from it will return its default value. + mutating func clearWifiLanUsableChannels() {self._wifiLanUsableChannels = nil} + + /// Usable WiFi Aware channels on the local device. + var wifiAwareUsableChannels: Location_Nearby_Connections_WifiAwareUsableChannels { + get {return _wifiAwareUsableChannels ?? Location_Nearby_Connections_WifiAwareUsableChannels()} + set {_wifiAwareUsableChannels = newValue} + } + /// Returns true if `wifiAwareUsableChannels` has been explicitly set. + var hasWifiAwareUsableChannels: Bool {return self._wifiAwareUsableChannels != nil} + /// Clears the value of `wifiAwareUsableChannels`. Subsequent reads from it will return its default value. + mutating func clearWifiAwareUsableChannels() {self._wifiAwareUsableChannels = nil} + + /// Usable WiFi Hotspot STA channels on the local device. + var wifiHotspotStaUsableChannels: Location_Nearby_Connections_WifiHotspotStaUsableChannels { + get {return _wifiHotspotStaUsableChannels ?? Location_Nearby_Connections_WifiHotspotStaUsableChannels()} + set {_wifiHotspotStaUsableChannels = newValue} + } + /// Returns true if `wifiHotspotStaUsableChannels` has been explicitly set. + var hasWifiHotspotStaUsableChannels: Bool {return self._wifiHotspotStaUsableChannels != nil} + /// Clears the value of `wifiHotspotStaUsableChannels`. Subsequent reads from it will return its default value. + mutating func clearWifiHotspotStaUsableChannels() {self._wifiHotspotStaUsableChannels = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _supports5Ghz: Bool? = nil + fileprivate var _bssid: String? = nil + fileprivate var _ipAddress: Data? = nil + fileprivate var _supports6Ghz: Bool? = nil + fileprivate var _mobileRadio: Bool? = nil + fileprivate var _apFrequency: Int32? = nil + fileprivate var _availableChannels: Location_Nearby_Connections_AvailableChannels? = nil + fileprivate var _wifiDirectCliUsableChannels: Location_Nearby_Connections_WifiDirectCliUsableChannels? = nil + fileprivate var _wifiLanUsableChannels: Location_Nearby_Connections_WifiLanUsableChannels? = nil + fileprivate var _wifiAwareUsableChannels: Location_Nearby_Connections_WifiAwareUsableChannels? = nil + fileprivate var _wifiHotspotStaUsableChannels: Location_Nearby_Connections_WifiHotspotStaUsableChannels? = nil +} + +/// Available channels on the local device. +struct Location_Nearby_Connections_AvailableChannels { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var channels: [Int32] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +/// Usable WiFi Direct client channels on the local device. +struct Location_Nearby_Connections_WifiDirectCliUsableChannels { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var channels: [Int32] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +/// Usable WiFi LAN channels on the local device. +struct Location_Nearby_Connections_WifiLanUsableChannels { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var channels: [Int32] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +/// Usable WiFi Aware channels on the local device. +struct Location_Nearby_Connections_WifiAwareUsableChannels { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var channels: [Int32] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +/// Usable WiFi Hotspot STA channels on the local device. +struct Location_Nearby_Connections_WifiHotspotStaUsableChannels { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var channels: [Int32] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +/// LocationHint is used to specify a location as well as format. +struct Location_Nearby_Connections_LocationHint { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Location is the location, provided in the format specified by format. + var location: String { + get {return _location ?? String()} + set {_location = newValue} + } + /// Returns true if `location` has been explicitly set. + var hasLocation: Bool {return self._location != nil} + /// Clears the value of `location`. Subsequent reads from it will return its default value. + mutating func clearLocation() {self._location = nil} + + /// the format of location. + var format: Location_Nearby_Connections_LocationStandard.Format { + get {return _format ?? .unknown} + set {_format = newValue} + } + /// Returns true if `format` has been explicitly set. + var hasFormat: Bool {return self._format != nil} + /// Clears the value of `format`. Subsequent reads from it will return its default value. + mutating func clearFormat() {self._format = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _location: String? = nil + fileprivate var _format: Location_Nearby_Connections_LocationStandard.Format? = nil +} + +struct Location_Nearby_Connections_LocationStandard { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum Format: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknown // = 0 + + /// E164 country codes: + /// https://en.wikipedia.org/wiki/List_of_country_calling_codes + /// e.g. +1 for USA + case e164Calling // = 1 + + /// ISO 3166-1 alpha-2 country codes: + /// https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + case iso31661Alpha2 // = 2 + + init() { + self = .unknown + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknown + case 1: self = .e164Calling + case 2: self = .iso31661Alpha2 + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknown: return 0 + case .e164Calling: return 1 + case .iso31661Alpha2: return 2 + } + } + + } + + init() {} +} + +#if swift(>=4.2) + +extension Location_Nearby_Connections_LocationStandard.Format: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// Device capability for OS information. +struct Location_Nearby_Connections_OsInfo { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var type: Location_Nearby_Connections_OsInfo.OsType { + get {return _type ?? .unknownOsType} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum OsType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownOsType // = 0 + case android // = 1 + case chromeOs // = 2 + case windows // = 3 + case apple // = 4 + + /// g3 test environment + case linux // = 100 + + init() { + self = .unknownOsType + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownOsType + case 1: self = .android + case 2: self = .chromeOs + case 3: self = .windows + case 4: self = .apple + case 100: self = .linux + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownOsType: return 0 + case .android: return 1 + case .chromeOs: return 2 + case .windows: return 3 + case .apple: return 4 + case .linux: return 100 + } + } + + } + + init() {} + + fileprivate var _type: Location_Nearby_Connections_OsInfo.OsType? = nil +} + +#if swift(>=4.2) + +extension Location_Nearby_Connections_OsInfo.OsType: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +#if swift(>=5.5) && canImport(_Concurrency) +extension Location_Nearby_Connections_OfflineFrame: @unchecked Sendable {} +extension Location_Nearby_Connections_OfflineFrame.Version: @unchecked Sendable {} +extension Location_Nearby_Connections_V1Frame: @unchecked Sendable {} +extension Location_Nearby_Connections_V1Frame.FrameType: @unchecked Sendable {} +extension Location_Nearby_Connections_ConnectionRequestFrame: @unchecked Sendable {} +extension Location_Nearby_Connections_ConnectionRequestFrame.Medium: @unchecked Sendable {} +extension Location_Nearby_Connections_ConnectionResponseFrame: @unchecked Sendable {} +extension Location_Nearby_Connections_ConnectionResponseFrame.ResponseStatus: @unchecked Sendable {} +extension Location_Nearby_Connections_PayloadTransferFrame: @unchecked Sendable {} +extension Location_Nearby_Connections_PayloadTransferFrame.PacketType: @unchecked Sendable {} +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader: @unchecked Sendable {} +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader.PayloadType: @unchecked Sendable {} +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk: @unchecked Sendable {} +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk.Flags: @unchecked Sendable {} +extension Location_Nearby_Connections_PayloadTransferFrame.ControlMessage: @unchecked Sendable {} +extension Location_Nearby_Connections_PayloadTransferFrame.ControlMessage.EventType: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.EventType: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.Medium: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiHotspotCredentials: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiLanSocket: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.BluetoothCredentials: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiAwareCredentials: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WebRtcCredentials: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroduction: @unchecked Sendable {} +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroductionAck: @unchecked Sendable {} +extension Location_Nearby_Connections_KeepAliveFrame: @unchecked Sendable {} +extension Location_Nearby_Connections_DisconnectionFrame: @unchecked Sendable {} +extension Location_Nearby_Connections_PairedKeyEncryptionFrame: @unchecked Sendable {} +extension Location_Nearby_Connections_MediumMetadata: @unchecked Sendable {} +extension Location_Nearby_Connections_AvailableChannels: @unchecked Sendable {} +extension Location_Nearby_Connections_WifiDirectCliUsableChannels: @unchecked Sendable {} +extension Location_Nearby_Connections_WifiLanUsableChannels: @unchecked Sendable {} +extension Location_Nearby_Connections_WifiAwareUsableChannels: @unchecked Sendable {} +extension Location_Nearby_Connections_WifiHotspotStaUsableChannels: @unchecked Sendable {} +extension Location_Nearby_Connections_LocationHint: @unchecked Sendable {} +extension Location_Nearby_Connections_LocationStandard: @unchecked Sendable {} +extension Location_Nearby_Connections_LocationStandard.Format: @unchecked Sendable {} +extension Location_Nearby_Connections_OsInfo: @unchecked Sendable {} +extension Location_Nearby_Connections_OsInfo.OsType: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "location.nearby.connections" + +extension Location_Nearby_Connections_OfflineFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".OfflineFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "version"), + 2: .same(proto: "v1"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._version) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._v1) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._version { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._v1 { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_OfflineFrame, rhs: Location_Nearby_Connections_OfflineFrame) -> Bool { + if lhs._version != rhs._version {return false} + if lhs._v1 != rhs._v1 {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_OfflineFrame.Version: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_VERSION"), + 1: .same(proto: "V1"), + ] +} + +extension Location_Nearby_Connections_V1Frame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".V1Frame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "connection_request"), + 3: .standard(proto: "connection_response"), + 4: .standard(proto: "payload_transfer"), + 5: .standard(proto: "bandwidth_upgrade_negotiation"), + 6: .standard(proto: "keep_alive"), + 7: .same(proto: "disconnection"), + 8: .standard(proto: "paired_key_encryption"), + ] + + fileprivate class _StorageClass { + var _type: Location_Nearby_Connections_V1Frame.FrameType? = nil + var _connectionRequest: Location_Nearby_Connections_ConnectionRequestFrame? = nil + var _connectionResponse: Location_Nearby_Connections_ConnectionResponseFrame? = nil + var _payloadTransfer: Location_Nearby_Connections_PayloadTransferFrame? = nil + var _bandwidthUpgradeNegotiation: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame? = nil + var _keepAlive: Location_Nearby_Connections_KeepAliveFrame? = nil + var _disconnection: Location_Nearby_Connections_DisconnectionFrame? = nil + var _pairedKeyEncryption: Location_Nearby_Connections_PairedKeyEncryptionFrame? = nil + + static let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _type = source._type + _connectionRequest = source._connectionRequest + _connectionResponse = source._connectionResponse + _payloadTransfer = source._payloadTransfer + _bandwidthUpgradeNegotiation = source._bandwidthUpgradeNegotiation + _keepAlive = source._keepAlive + _disconnection = source._disconnection + _pairedKeyEncryption = source._pairedKeyEncryption + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + + mutating func decodeMessage(decoder: inout D) throws { + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &_storage._type) }() + case 2: try { try decoder.decodeSingularMessageField(value: &_storage._connectionRequest) }() + case 3: try { try decoder.decodeSingularMessageField(value: &_storage._connectionResponse) }() + case 4: try { try decoder.decodeSingularMessageField(value: &_storage._payloadTransfer) }() + case 5: try { try decoder.decodeSingularMessageField(value: &_storage._bandwidthUpgradeNegotiation) }() + case 6: try { try decoder.decodeSingularMessageField(value: &_storage._keepAlive) }() + case 7: try { try decoder.decodeSingularMessageField(value: &_storage._disconnection) }() + case 8: try { try decoder.decodeSingularMessageField(value: &_storage._pairedKeyEncryption) }() + default: break + } + } + } + } + + func traverse(visitor: inout V) throws { + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = _storage._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = _storage._connectionRequest { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try { if let v = _storage._connectionResponse { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try { if let v = _storage._payloadTransfer { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } }() + try { if let v = _storage._bandwidthUpgradeNegotiation { + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + } }() + try { if let v = _storage._keepAlive { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() + try { if let v = _storage._disconnection { + try visitor.visitSingularMessageField(value: v, fieldNumber: 7) + } }() + try { if let v = _storage._pairedKeyEncryption { + try visitor.visitSingularMessageField(value: v, fieldNumber: 8) + } }() + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_V1Frame, rhs: Location_Nearby_Connections_V1Frame) -> Bool { + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._type != rhs_storage._type {return false} + if _storage._connectionRequest != rhs_storage._connectionRequest {return false} + if _storage._connectionResponse != rhs_storage._connectionResponse {return false} + if _storage._payloadTransfer != rhs_storage._payloadTransfer {return false} + if _storage._bandwidthUpgradeNegotiation != rhs_storage._bandwidthUpgradeNegotiation {return false} + if _storage._keepAlive != rhs_storage._keepAlive {return false} + if _storage._disconnection != rhs_storage._disconnection {return false} + if _storage._pairedKeyEncryption != rhs_storage._pairedKeyEncryption {return false} + return true + } + if !storagesAreEqual {return false} + } + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_V1Frame.FrameType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_FRAME_TYPE"), + 1: .same(proto: "CONNECTION_REQUEST"), + 2: .same(proto: "CONNECTION_RESPONSE"), + 3: .same(proto: "PAYLOAD_TRANSFER"), + 4: .same(proto: "BANDWIDTH_UPGRADE_NEGOTIATION"), + 5: .same(proto: "KEEP_ALIVE"), + 6: .same(proto: "DISCONNECTION"), + 7: .same(proto: "PAIRED_KEY_ENCRYPTION"), + ] +} + +extension Location_Nearby_Connections_ConnectionRequestFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ConnectionRequestFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "endpoint_id"), + 2: .standard(proto: "endpoint_name"), + 3: .standard(proto: "handshake_data"), + 4: .same(proto: "nonce"), + 5: .same(proto: "mediums"), + 6: .standard(proto: "endpoint_info"), + 7: .standard(proto: "medium_metadata"), + 8: .standard(proto: "keep_alive_interval_millis"), + 9: .standard(proto: "keep_alive_timeout_millis"), + 10: .standard(proto: "device_type"), + 11: .standard(proto: "device_info"), + ] + + fileprivate class _StorageClass { + var _endpointID: String? = nil + var _endpointName: String? = nil + var _handshakeData: Data? = nil + var _nonce: Int32? = nil + var _mediums: [Location_Nearby_Connections_ConnectionRequestFrame.Medium] = [] + var _endpointInfo: Data? = nil + var _mediumMetadata: Location_Nearby_Connections_MediumMetadata? = nil + var _keepAliveIntervalMillis: Int32? = nil + var _keepAliveTimeoutMillis: Int32? = nil + var _deviceType: Int32? = nil + var _deviceInfo: Data? = nil + + static let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _endpointID = source._endpointID + _endpointName = source._endpointName + _handshakeData = source._handshakeData + _nonce = source._nonce + _mediums = source._mediums + _endpointInfo = source._endpointInfo + _mediumMetadata = source._mediumMetadata + _keepAliveIntervalMillis = source._keepAliveIntervalMillis + _keepAliveTimeoutMillis = source._keepAliveTimeoutMillis + _deviceType = source._deviceType + _deviceInfo = source._deviceInfo + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + + mutating func decodeMessage(decoder: inout D) throws { + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &_storage._endpointID) }() + case 2: try { try decoder.decodeSingularStringField(value: &_storage._endpointName) }() + case 3: try { try decoder.decodeSingularBytesField(value: &_storage._handshakeData) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &_storage._nonce) }() + case 5: try { try decoder.decodeRepeatedEnumField(value: &_storage._mediums) }() + case 6: try { try decoder.decodeSingularBytesField(value: &_storage._endpointInfo) }() + case 7: try { try decoder.decodeSingularMessageField(value: &_storage._mediumMetadata) }() + case 8: try { try decoder.decodeSingularInt32Field(value: &_storage._keepAliveIntervalMillis) }() + case 9: try { try decoder.decodeSingularInt32Field(value: &_storage._keepAliveTimeoutMillis) }() + case 10: try { try decoder.decodeSingularInt32Field(value: &_storage._deviceType) }() + case 11: try { try decoder.decodeSingularBytesField(value: &_storage._deviceInfo) }() + default: break + } + } + } + } + + func traverse(visitor: inout V) throws { + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = _storage._endpointID { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = _storage._endpointName { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = _storage._handshakeData { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try { if let v = _storage._nonce { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 4) + } }() + if !_storage._mediums.isEmpty { + try visitor.visitRepeatedEnumField(value: _storage._mediums, fieldNumber: 5) + } + try { if let v = _storage._endpointInfo { + try visitor.visitSingularBytesField(value: v, fieldNumber: 6) + } }() + try { if let v = _storage._mediumMetadata { + try visitor.visitSingularMessageField(value: v, fieldNumber: 7) + } }() + try { if let v = _storage._keepAliveIntervalMillis { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 8) + } }() + try { if let v = _storage._keepAliveTimeoutMillis { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 9) + } }() + try { if let v = _storage._deviceType { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 10) + } }() + try { if let v = _storage._deviceInfo { + try visitor.visitSingularBytesField(value: v, fieldNumber: 11) + } }() + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_ConnectionRequestFrame, rhs: Location_Nearby_Connections_ConnectionRequestFrame) -> Bool { + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._endpointID != rhs_storage._endpointID {return false} + if _storage._endpointName != rhs_storage._endpointName {return false} + if _storage._handshakeData != rhs_storage._handshakeData {return false} + if _storage._nonce != rhs_storage._nonce {return false} + if _storage._mediums != rhs_storage._mediums {return false} + if _storage._endpointInfo != rhs_storage._endpointInfo {return false} + if _storage._mediumMetadata != rhs_storage._mediumMetadata {return false} + if _storage._keepAliveIntervalMillis != rhs_storage._keepAliveIntervalMillis {return false} + if _storage._keepAliveTimeoutMillis != rhs_storage._keepAliveTimeoutMillis {return false} + if _storage._deviceType != rhs_storage._deviceType {return false} + if _storage._deviceInfo != rhs_storage._deviceInfo {return false} + return true + } + if !storagesAreEqual {return false} + } + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_ConnectionRequestFrame.Medium: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_MEDIUM"), + 1: .same(proto: "MDNS"), + 2: .same(proto: "BLUETOOTH"), + 3: .same(proto: "WIFI_HOTSPOT"), + 4: .same(proto: "BLE"), + 5: .same(proto: "WIFI_LAN"), + 6: .same(proto: "WIFI_AWARE"), + 7: .same(proto: "NFC"), + 8: .same(proto: "WIFI_DIRECT"), + 9: .same(proto: "WEB_RTC"), + 10: .same(proto: "BLE_L2CAP"), + 11: .same(proto: "USB"), + ] +} + +extension Location_Nearby_Connections_ConnectionResponseFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ConnectionResponseFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + 2: .standard(proto: "handshake_data"), + 3: .same(proto: "response"), + 4: .standard(proto: "os_info"), + 5: .standard(proto: "multiplex_socket_bitmask"), + 6: .standard(proto: "nearby_connections_version"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self._status) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._handshakeData) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self._response) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._osInfo) }() + case 5: try { try decoder.decodeSingularInt32Field(value: &self._multiplexSocketBitmask) }() + case 6: try { try decoder.decodeSingularInt32Field(value: &self._nearbyConnectionsVersion) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._status { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 1) + } }() + try { if let v = self._handshakeData { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try { if let v = self._response { + try visitor.visitSingularEnumField(value: v, fieldNumber: 3) + } }() + try { if let v = self._osInfo { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } }() + try { if let v = self._multiplexSocketBitmask { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 5) + } }() + try { if let v = self._nearbyConnectionsVersion { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 6) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_ConnectionResponseFrame, rhs: Location_Nearby_Connections_ConnectionResponseFrame) -> Bool { + if lhs._status != rhs._status {return false} + if lhs._handshakeData != rhs._handshakeData {return false} + if lhs._response != rhs._response {return false} + if lhs._osInfo != rhs._osInfo {return false} + if lhs._multiplexSocketBitmask != rhs._multiplexSocketBitmask {return false} + if lhs._nearbyConnectionsVersion != rhs._nearbyConnectionsVersion {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_ConnectionResponseFrame.ResponseStatus: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_RESPONSE_STATUS"), + 1: .same(proto: "ACCEPT"), + 2: .same(proto: "REJECT"), + ] +} + +extension Location_Nearby_Connections_PayloadTransferFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".PayloadTransferFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "packet_type"), + 2: .standard(proto: "payload_header"), + 3: .standard(proto: "payload_chunk"), + 4: .standard(proto: "control_message"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._packetType) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._payloadHeader) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._payloadChunk) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._controlMessage) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._packetType { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._payloadHeader { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try { if let v = self._payloadChunk { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try { if let v = self._controlMessage { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_PayloadTransferFrame, rhs: Location_Nearby_Connections_PayloadTransferFrame) -> Bool { + if lhs._packetType != rhs._packetType {return false} + if lhs._payloadHeader != rhs._payloadHeader {return false} + if lhs._payloadChunk != rhs._payloadChunk {return false} + if lhs._controlMessage != rhs._controlMessage {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_PayloadTransferFrame.PacketType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_PACKET_TYPE"), + 1: .same(proto: "DATA"), + 2: .same(proto: "CONTROL"), + ] +} + +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_PayloadTransferFrame.protoMessageName + ".PayloadHeader" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .same(proto: "type"), + 3: .standard(proto: "total_size"), + 4: .standard(proto: "is_sensitive"), + 5: .standard(proto: "file_name"), + 6: .standard(proto: "parent_folder"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt64Field(value: &self._id) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self._type) }() + case 3: try { try decoder.decodeSingularInt64Field(value: &self._totalSize) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self._isSensitive) }() + case 5: try { try decoder.decodeSingularStringField(value: &self._fileName) }() + case 6: try { try decoder.decodeSingularStringField(value: &self._parentFolder) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._id { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 1) + } }() + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 2) + } }() + try { if let v = self._totalSize { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 3) + } }() + try { if let v = self._isSensitive { + try visitor.visitSingularBoolField(value: v, fieldNumber: 4) + } }() + try { if let v = self._fileName { + try visitor.visitSingularStringField(value: v, fieldNumber: 5) + } }() + try { if let v = self._parentFolder { + try visitor.visitSingularStringField(value: v, fieldNumber: 6) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader, rhs: Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader) -> Bool { + if lhs._id != rhs._id {return false} + if lhs._type != rhs._type {return false} + if lhs._totalSize != rhs._totalSize {return false} + if lhs._isSensitive != rhs._isSensitive {return false} + if lhs._fileName != rhs._fileName {return false} + if lhs._parentFolder != rhs._parentFolder {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadHeader.PayloadType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_PAYLOAD_TYPE"), + 1: .same(proto: "BYTES"), + 2: .same(proto: "FILE"), + 3: .same(proto: "STREAM"), + ] +} + +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_PayloadTransferFrame.protoMessageName + ".PayloadChunk" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "flags"), + 2: .same(proto: "offset"), + 3: .same(proto: "body"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self._flags) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &self._offset) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._body) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._flags { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 1) + } }() + try { if let v = self._offset { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 2) + } }() + try { if let v = self._body { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk, rhs: Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk) -> Bool { + if lhs._flags != rhs._flags {return false} + if lhs._offset != rhs._offset {return false} + if lhs._body != rhs._body {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_PayloadTransferFrame.PayloadChunk.Flags: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "LAST_CHUNK"), + ] +} + +extension Location_Nearby_Connections_PayloadTransferFrame.ControlMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_PayloadTransferFrame.protoMessageName + ".ControlMessage" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "event"), + 2: .same(proto: "offset"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._event) }() + case 2: try { try decoder.decodeSingularInt64Field(value: &self._offset) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._event { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._offset { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_PayloadTransferFrame.ControlMessage, rhs: Location_Nearby_Connections_PayloadTransferFrame.ControlMessage) -> Bool { + if lhs._event != rhs._event {return false} + if lhs._offset != rhs._offset {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_PayloadTransferFrame.ControlMessage.EventType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_EVENT_TYPE"), + 1: .same(proto: "PAYLOAD_ERROR"), + 2: .same(proto: "PAYLOAD_CANCELED"), + 3: .same(proto: "PAYLOAD_RECEIVED_ACK"), + ] +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".BandwidthUpgradeNegotiationFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "event_type"), + 2: .standard(proto: "upgrade_path_info"), + 3: .standard(proto: "client_introduction"), + 4: .standard(proto: "client_introduction_ack"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._eventType) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._upgradePathInfo) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._clientIntroduction) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._clientIntroductionAck) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._eventType { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._upgradePathInfo { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try { if let v = self._clientIntroduction { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try { if let v = self._clientIntroductionAck { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame) -> Bool { + if lhs._eventType != rhs._eventType {return false} + if lhs._upgradePathInfo != rhs._upgradePathInfo {return false} + if lhs._clientIntroduction != rhs._clientIntroduction {return false} + if lhs._clientIntroductionAck != rhs._clientIntroductionAck {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.EventType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_EVENT_TYPE"), + 1: .same(proto: "UPGRADE_PATH_AVAILABLE"), + 2: .same(proto: "LAST_WRITE_TO_PRIOR_CHANNEL"), + 3: .same(proto: "SAFE_TO_CLOSE_PRIOR_CHANNEL"), + 4: .same(proto: "CLIENT_INTRODUCTION"), + 5: .same(proto: "UPGRADE_FAILURE"), + 6: .same(proto: "CLIENT_INTRODUCTION_ACK"), + ] +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.protoMessageName + ".UpgradePathInfo" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "medium"), + 2: .standard(proto: "wifi_hotspot_credentials"), + 3: .standard(proto: "wifi_lan_socket"), + 4: .standard(proto: "bluetooth_credentials"), + 5: .standard(proto: "wifi_aware_credentials"), + 6: .standard(proto: "wifi_direct_credentials"), + 8: .standard(proto: "web_rtc_credentials"), + 7: .standard(proto: "supports_disabling_encryption"), + 9: .standard(proto: "supports_client_introduction_ack"), + ] + + fileprivate class _StorageClass { + var _medium: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.Medium? = nil + var _wifiHotspotCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiHotspotCredentials? = nil + var _wifiLanSocket: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiLanSocket? = nil + var _bluetoothCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.BluetoothCredentials? = nil + var _wifiAwareCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiAwareCredentials? = nil + var _wifiDirectCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials? = nil + var _webRtcCredentials: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WebRtcCredentials? = nil + var _supportsDisablingEncryption: Bool? = nil + var _supportsClientIntroductionAck: Bool? = nil + + static let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _medium = source._medium + _wifiHotspotCredentials = source._wifiHotspotCredentials + _wifiLanSocket = source._wifiLanSocket + _bluetoothCredentials = source._bluetoothCredentials + _wifiAwareCredentials = source._wifiAwareCredentials + _wifiDirectCredentials = source._wifiDirectCredentials + _webRtcCredentials = source._webRtcCredentials + _supportsDisablingEncryption = source._supportsDisablingEncryption + _supportsClientIntroductionAck = source._supportsClientIntroductionAck + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + + mutating func decodeMessage(decoder: inout D) throws { + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &_storage._medium) }() + case 2: try { try decoder.decodeSingularMessageField(value: &_storage._wifiHotspotCredentials) }() + case 3: try { try decoder.decodeSingularMessageField(value: &_storage._wifiLanSocket) }() + case 4: try { try decoder.decodeSingularMessageField(value: &_storage._bluetoothCredentials) }() + case 5: try { try decoder.decodeSingularMessageField(value: &_storage._wifiAwareCredentials) }() + case 6: try { try decoder.decodeSingularMessageField(value: &_storage._wifiDirectCredentials) }() + case 7: try { try decoder.decodeSingularBoolField(value: &_storage._supportsDisablingEncryption) }() + case 8: try { try decoder.decodeSingularMessageField(value: &_storage._webRtcCredentials) }() + case 9: try { try decoder.decodeSingularBoolField(value: &_storage._supportsClientIntroductionAck) }() + default: break + } + } + } + } + + func traverse(visitor: inout V) throws { + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = _storage._medium { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = _storage._wifiHotspotCredentials { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try { if let v = _storage._wifiLanSocket { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try { if let v = _storage._bluetoothCredentials { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } }() + try { if let v = _storage._wifiAwareCredentials { + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + } }() + try { if let v = _storage._wifiDirectCredentials { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() + try { if let v = _storage._supportsDisablingEncryption { + try visitor.visitSingularBoolField(value: v, fieldNumber: 7) + } }() + try { if let v = _storage._webRtcCredentials { + try visitor.visitSingularMessageField(value: v, fieldNumber: 8) + } }() + try { if let v = _storage._supportsClientIntroductionAck { + try visitor.visitSingularBoolField(value: v, fieldNumber: 9) + } }() + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo) -> Bool { + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._medium != rhs_storage._medium {return false} + if _storage._wifiHotspotCredentials != rhs_storage._wifiHotspotCredentials {return false} + if _storage._wifiLanSocket != rhs_storage._wifiLanSocket {return false} + if _storage._bluetoothCredentials != rhs_storage._bluetoothCredentials {return false} + if _storage._wifiAwareCredentials != rhs_storage._wifiAwareCredentials {return false} + if _storage._wifiDirectCredentials != rhs_storage._wifiDirectCredentials {return false} + if _storage._webRtcCredentials != rhs_storage._webRtcCredentials {return false} + if _storage._supportsDisablingEncryption != rhs_storage._supportsDisablingEncryption {return false} + if _storage._supportsClientIntroductionAck != rhs_storage._supportsClientIntroductionAck {return false} + return true + } + if !storagesAreEqual {return false} + } + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.Medium: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_MEDIUM"), + 1: .same(proto: "MDNS"), + 2: .same(proto: "BLUETOOTH"), + 3: .same(proto: "WIFI_HOTSPOT"), + 4: .same(proto: "BLE"), + 5: .same(proto: "WIFI_LAN"), + 6: .same(proto: "WIFI_AWARE"), + 7: .same(proto: "NFC"), + 8: .same(proto: "WIFI_DIRECT"), + 9: .same(proto: "WEB_RTC"), + 11: .same(proto: "USB"), + ] +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiHotspotCredentials: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.protoMessageName + ".WifiHotspotCredentials" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "ssid"), + 2: .same(proto: "password"), + 3: .same(proto: "port"), + 4: .same(proto: "gateway"), + 5: .same(proto: "frequency"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._ssid) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._password) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self._port) }() + case 4: try { try decoder.decodeSingularStringField(value: &self._gateway) }() + case 5: try { try decoder.decodeSingularInt32Field(value: &self._frequency) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._ssid { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._password { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = self._port { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 3) + } }() + try { if let v = self._gateway { + try visitor.visitSingularStringField(value: v, fieldNumber: 4) + } }() + try { if let v = self._frequency { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 5) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiHotspotCredentials, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiHotspotCredentials) -> Bool { + if lhs._ssid != rhs._ssid {return false} + if lhs._password != rhs._password {return false} + if lhs._port != rhs._port {return false} + if lhs._gateway != rhs._gateway {return false} + if lhs._frequency != rhs._frequency {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiLanSocket: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.protoMessageName + ".WifiLanSocket" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "ip_address"), + 2: .standard(proto: "wifi_port"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._ipAddress) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self._wifiPort) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._ipAddress { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._wifiPort { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiLanSocket, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiLanSocket) -> Bool { + if lhs._ipAddress != rhs._ipAddress {return false} + if lhs._wifiPort != rhs._wifiPort {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.BluetoothCredentials: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.protoMessageName + ".BluetoothCredentials" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "service_name"), + 2: .standard(proto: "mac_address"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._serviceName) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._macAddress) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._serviceName { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._macAddress { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.BluetoothCredentials, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.BluetoothCredentials) -> Bool { + if lhs._serviceName != rhs._serviceName {return false} + if lhs._macAddress != rhs._macAddress {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiAwareCredentials: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.protoMessageName + ".WifiAwareCredentials" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "service_id"), + 2: .standard(proto: "service_info"), + 3: .same(proto: "password"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._serviceID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._serviceInfo) }() + case 3: try { try decoder.decodeSingularStringField(value: &self._password) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._serviceID { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._serviceInfo { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try { if let v = self._password { + try visitor.visitSingularStringField(value: v, fieldNumber: 3) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiAwareCredentials, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiAwareCredentials) -> Bool { + if lhs._serviceID != rhs._serviceID {return false} + if lhs._serviceInfo != rhs._serviceInfo {return false} + if lhs._password != rhs._password {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.protoMessageName + ".WifiDirectCredentials" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "ssid"), + 2: .same(proto: "password"), + 3: .same(proto: "port"), + 4: .same(proto: "frequency"), + 5: .same(proto: "gateway"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._ssid) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._password) }() + case 3: try { try decoder.decodeSingularInt32Field(value: &self._port) }() + case 4: try { try decoder.decodeSingularInt32Field(value: &self._frequency) }() + case 5: try { try decoder.decodeSingularStringField(value: &self._gateway) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._ssid { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._password { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = self._port { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 3) + } }() + try { if let v = self._frequency { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 4) + } }() + try { if let v = self._gateway { + try visitor.visitSingularStringField(value: v, fieldNumber: 5) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WifiDirectCredentials) -> Bool { + if lhs._ssid != rhs._ssid {return false} + if lhs._password != rhs._password {return false} + if lhs._port != rhs._port {return false} + if lhs._frequency != rhs._frequency {return false} + if lhs._gateway != rhs._gateway {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WebRtcCredentials: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.protoMessageName + ".WebRtcCredentials" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "peer_id"), + 2: .standard(proto: "location_hint"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._peerID) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._locationHint) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._peerID { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._locationHint { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WebRtcCredentials, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.UpgradePathInfo.WebRtcCredentials) -> Bool { + if lhs._peerID != rhs._peerID {return false} + if lhs._locationHint != rhs._locationHint {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroduction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.protoMessageName + ".ClientIntroduction" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "endpoint_id"), + 2: .standard(proto: "supports_disabling_encryption"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._endpointID) }() + case 2: try { try decoder.decodeSingularBoolField(value: &self._supportsDisablingEncryption) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._endpointID { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._supportsDisablingEncryption { + try visitor.visitSingularBoolField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroduction, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroduction) -> Bool { + if lhs._endpointID != rhs._endpointID {return false} + if lhs._supportsDisablingEncryption != rhs._supportsDisablingEncryption {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroductionAck: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.protoMessageName + ".ClientIntroductionAck" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroductionAck, rhs: Location_Nearby_Connections_BandwidthUpgradeNegotiationFrame.ClientIntroductionAck) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_KeepAliveFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".KeepAliveFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "ack"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &self._ack) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._ack { + try visitor.visitSingularBoolField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_KeepAliveFrame, rhs: Location_Nearby_Connections_KeepAliveFrame) -> Bool { + if lhs._ack != rhs._ack {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_DisconnectionFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".DisconnectionFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "request_safe_to_disconnect"), + 2: .standard(proto: "ack_safe_to_disconnect"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &self._requestSafeToDisconnect) }() + case 2: try { try decoder.decodeSingularBoolField(value: &self._ackSafeToDisconnect) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._requestSafeToDisconnect { + try visitor.visitSingularBoolField(value: v, fieldNumber: 1) + } }() + try { if let v = self._ackSafeToDisconnect { + try visitor.visitSingularBoolField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_DisconnectionFrame, rhs: Location_Nearby_Connections_DisconnectionFrame) -> Bool { + if lhs._requestSafeToDisconnect != rhs._requestSafeToDisconnect {return false} + if lhs._ackSafeToDisconnect != rhs._ackSafeToDisconnect {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_PairedKeyEncryptionFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".PairedKeyEncryptionFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "signed_data"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._signedData) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._signedData { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_PairedKeyEncryptionFrame, rhs: Location_Nearby_Connections_PairedKeyEncryptionFrame) -> Bool { + if lhs._signedData != rhs._signedData {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_MediumMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".MediumMetadata" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "supports_5_ghz"), + 2: .same(proto: "bssid"), + 3: .standard(proto: "ip_address"), + 4: .standard(proto: "supports_6_ghz"), + 5: .standard(proto: "mobile_radio"), + 6: .standard(proto: "ap_frequency"), + 7: .standard(proto: "available_channels"), + 8: .standard(proto: "wifi_direct_cli_usable_channels"), + 9: .standard(proto: "wifi_lan_usable_channels"), + 10: .standard(proto: "wifi_aware_usable_channels"), + 11: .standard(proto: "wifi_hotspot_sta_usable_channels"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBoolField(value: &self._supports5Ghz) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._bssid) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._ipAddress) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self._supports6Ghz) }() + case 5: try { try decoder.decodeSingularBoolField(value: &self._mobileRadio) }() + case 6: try { try decoder.decodeSingularInt32Field(value: &self._apFrequency) }() + case 7: try { try decoder.decodeSingularMessageField(value: &self._availableChannels) }() + case 8: try { try decoder.decodeSingularMessageField(value: &self._wifiDirectCliUsableChannels) }() + case 9: try { try decoder.decodeSingularMessageField(value: &self._wifiLanUsableChannels) }() + case 10: try { try decoder.decodeSingularMessageField(value: &self._wifiAwareUsableChannels) }() + case 11: try { try decoder.decodeSingularMessageField(value: &self._wifiHotspotStaUsableChannels) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._supports5Ghz { + try visitor.visitSingularBoolField(value: v, fieldNumber: 1) + } }() + try { if let v = self._bssid { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = self._ipAddress { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try { if let v = self._supports6Ghz { + try visitor.visitSingularBoolField(value: v, fieldNumber: 4) + } }() + try { if let v = self._mobileRadio { + try visitor.visitSingularBoolField(value: v, fieldNumber: 5) + } }() + try { if let v = self._apFrequency { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 6) + } }() + try { if let v = self._availableChannels { + try visitor.visitSingularMessageField(value: v, fieldNumber: 7) + } }() + try { if let v = self._wifiDirectCliUsableChannels { + try visitor.visitSingularMessageField(value: v, fieldNumber: 8) + } }() + try { if let v = self._wifiLanUsableChannels { + try visitor.visitSingularMessageField(value: v, fieldNumber: 9) + } }() + try { if let v = self._wifiAwareUsableChannels { + try visitor.visitSingularMessageField(value: v, fieldNumber: 10) + } }() + try { if let v = self._wifiHotspotStaUsableChannels { + try visitor.visitSingularMessageField(value: v, fieldNumber: 11) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_MediumMetadata, rhs: Location_Nearby_Connections_MediumMetadata) -> Bool { + if lhs._supports5Ghz != rhs._supports5Ghz {return false} + if lhs._bssid != rhs._bssid {return false} + if lhs._ipAddress != rhs._ipAddress {return false} + if lhs._supports6Ghz != rhs._supports6Ghz {return false} + if lhs._mobileRadio != rhs._mobileRadio {return false} + if lhs._apFrequency != rhs._apFrequency {return false} + if lhs._availableChannels != rhs._availableChannels {return false} + if lhs._wifiDirectCliUsableChannels != rhs._wifiDirectCliUsableChannels {return false} + if lhs._wifiLanUsableChannels != rhs._wifiLanUsableChannels {return false} + if lhs._wifiAwareUsableChannels != rhs._wifiAwareUsableChannels {return false} + if lhs._wifiHotspotStaUsableChannels != rhs._wifiHotspotStaUsableChannels {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_AvailableChannels: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".AvailableChannels" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "channels"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedInt32Field(value: &self.channels) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.channels.isEmpty { + try visitor.visitPackedInt32Field(value: self.channels, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_AvailableChannels, rhs: Location_Nearby_Connections_AvailableChannels) -> Bool { + if lhs.channels != rhs.channels {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_WifiDirectCliUsableChannels: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".WifiDirectCliUsableChannels" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "channels"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedInt32Field(value: &self.channels) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.channels.isEmpty { + try visitor.visitPackedInt32Field(value: self.channels, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_WifiDirectCliUsableChannels, rhs: Location_Nearby_Connections_WifiDirectCliUsableChannels) -> Bool { + if lhs.channels != rhs.channels {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_WifiLanUsableChannels: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".WifiLanUsableChannels" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "channels"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedInt32Field(value: &self.channels) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.channels.isEmpty { + try visitor.visitPackedInt32Field(value: self.channels, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_WifiLanUsableChannels, rhs: Location_Nearby_Connections_WifiLanUsableChannels) -> Bool { + if lhs.channels != rhs.channels {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_WifiAwareUsableChannels: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".WifiAwareUsableChannels" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "channels"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedInt32Field(value: &self.channels) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.channels.isEmpty { + try visitor.visitPackedInt32Field(value: self.channels, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_WifiAwareUsableChannels, rhs: Location_Nearby_Connections_WifiAwareUsableChannels) -> Bool { + if lhs.channels != rhs.channels {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_WifiHotspotStaUsableChannels: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".WifiHotspotStaUsableChannels" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "channels"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedInt32Field(value: &self.channels) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.channels.isEmpty { + try visitor.visitPackedInt32Field(value: self.channels, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_WifiHotspotStaUsableChannels, rhs: Location_Nearby_Connections_WifiHotspotStaUsableChannels) -> Bool { + if lhs.channels != rhs.channels {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_LocationHint: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".LocationHint" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "location"), + 2: .same(proto: "format"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._location) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self._format) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._location { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._format { + try visitor.visitSingularEnumField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_LocationHint, rhs: Location_Nearby_Connections_LocationHint) -> Bool { + if lhs._location != rhs._location {return false} + if lhs._format != rhs._format {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_LocationStandard: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".LocationStandard" + static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + mutating func decodeMessage(decoder: inout D) throws { + while let _ = try decoder.nextFieldNumber() { + } + } + + func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_LocationStandard, rhs: Location_Nearby_Connections_LocationStandard) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_LocationStandard.Format: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "E164_CALLING"), + 2: .same(proto: "ISO_3166_1_ALPHA_2"), + ] +} + +extension Location_Nearby_Connections_OsInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".OsInfo" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._type) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Location_Nearby_Connections_OsInfo, rhs: Location_Nearby_Connections_OsInfo) -> Bool { + if lhs._type != rhs._type {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Location_Nearby_Connections_OsInfo.OsType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_OS_TYPE"), + 1: .same(proto: "ANDROID"), + 2: .same(proto: "CHROME_OS"), + 3: .same(proto: "WINDOWS"), + 4: .same(proto: "APPLE"), + 100: .same(proto: "LINUX"), + ] +} diff --git a/NearDrop/Protobuf/securegcm.pb.swift b/NearDrop/Protobuf/securegcm.pb.swift new file mode 100644 index 0000000..5da7ecc --- /dev/null +++ b/NearDrop/Protobuf/securegcm.pb.swift @@ -0,0 +1,1522 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: securegcm.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// This enum is used by iOS devices as values for device_display_diagonal_mils +/// in GcmDeviceInfo. There is no good way to calculate it on those devices. +enum Securegcm_AppleDeviceDiagonalMils: SwiftProtobuf.Enum { + typealias RawValue = Int + + /// This is the mils diagonal on an iPhone 5. + case applePhone // = 4000 + + /// This is the mils diagonal on an iPad mini. + case applePad // = 7900 + + init() { + self = .applePhone + } + + init?(rawValue: Int) { + switch rawValue { + case 4000: self = .applePhone + case 7900: self = .applePad + default: return nil + } + } + + var rawValue: Int { + switch self { + case .applePhone: return 4000 + case .applePad: return 7900 + } + } + +} + +#if swift(>=4.2) + +extension Securegcm_AppleDeviceDiagonalMils: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// This should be kept in sync with DeviceType in: +/// java/com/google/security/cryptauth/backend/services/common/common_enums.proto +enum Securegcm_DeviceType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknown // = 0 + case android // = 1 + case chrome // = 2 + case ios // = 3 + case browser // = 4 + case osx // = 5 + + init() { + self = .unknown + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknown + case 1: self = .android + case 2: self = .chrome + case 3: self = .ios + case 4: self = .browser + case 5: self = .osx + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknown: return 0 + case .android: return 1 + case .chrome: return 2 + case .ios: return 3 + case .browser: return 4 + case .osx: return 5 + } + } + +} + +#if swift(>=4.2) + +extension Securegcm_DeviceType: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// MultiDevice features which may be supported and enabled on a device. See +enum Securegcm_SoftwareFeature: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownFeature // = 0 + case betterTogetherHost // = 1 + case betterTogetherClient // = 2 + case easyUnlockHost // = 3 + case easyUnlockClient // = 4 + case magicTetherHost // = 5 + case magicTetherClient // = 6 + case smsConnectHost // = 7 + case smsConnectClient // = 8 + + init() { + self = .unknownFeature + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownFeature + case 1: self = .betterTogetherHost + case 2: self = .betterTogetherClient + case 3: self = .easyUnlockHost + case 4: self = .easyUnlockClient + case 5: self = .magicTetherHost + case 6: self = .magicTetherClient + case 7: self = .smsConnectHost + case 8: self = .smsConnectClient + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownFeature: return 0 + case .betterTogetherHost: return 1 + case .betterTogetherClient: return 2 + case .easyUnlockHost: return 3 + case .easyUnlockClient: return 4 + case .magicTetherHost: return 5 + case .magicTetherClient: return 6 + case .smsConnectHost: return 7 + case .smsConnectClient: return 8 + } + } + +} + +#if swift(>=4.2) + +extension Securegcm_SoftwareFeature: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// A list of "reasons" that can be provided for calling server-side APIs. +/// This is particularly important for calls that can be triggered by different +/// kinds of events. Please try to keep reasons as generic as possible, so that +/// codes can be re-used by various callers in a sensible fashion. +enum Securegcm_InvocationReason: SwiftProtobuf.Enum { + typealias RawValue = Int + case reasonUnknown // = 0 + + /// First run of the software package invoking this call + case reasonInitialization // = 1 + + /// Ordinary periodic actions (e.g. monthly master key rotation) + case reasonPeriodic // = 2 + + /// Slow-cycle periodic action (e.g. yearly keypair rotation???) + case reasonSlowPeriodic // = 3 + + /// Fast-cycle periodic action (e.g. daily sync for Smart Lock users) + case reasonFastPeriodic // = 4 + + /// Expired state (e.g. expired credentials, or cached entries) was detected + case reasonExpiration // = 5 + + /// An unexpected protocol failure occurred (so attempting to repair state) + case reasonFailureRecovery // = 6 + + /// A new account has been added to the device + case reasonNewAccount // = 7 + + /// An existing account on the device has been changed + case reasonChangedAccount // = 8 + + /// The user toggled the state of a feature (e.g. Smart Lock enabled via BT) + case reasonFeatureToggled // = 9 + + /// A "push" from the server caused this action (e.g. a sync tickle) + case reasonServerInitiated // = 10 + + /// A local address change triggered this (e.g. GCM registration id changed) + case reasonAddressChange // = 11 + + /// A software update has triggered this + case reasonSoftwareUpdate // = 12 + + /// A manual action by the user triggered this (e.g. commands sent via adb) + case reasonManual // = 13 + + /// A custom key has been invalidated on the device (e.g. screen lock is + /// disabled). + case reasonCustomKeyInvalidation // = 14 + + /// Periodic action triggered by auth_proximity + case reasonProximityPeriodic // = 15 + + init() { + self = .reasonUnknown + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .reasonUnknown + case 1: self = .reasonInitialization + case 2: self = .reasonPeriodic + case 3: self = .reasonSlowPeriodic + case 4: self = .reasonFastPeriodic + case 5: self = .reasonExpiration + case 6: self = .reasonFailureRecovery + case 7: self = .reasonNewAccount + case 8: self = .reasonChangedAccount + case 9: self = .reasonFeatureToggled + case 10: self = .reasonServerInitiated + case 11: self = .reasonAddressChange + case 12: self = .reasonSoftwareUpdate + case 13: self = .reasonManual + case 14: self = .reasonCustomKeyInvalidation + case 15: self = .reasonProximityPeriodic + default: return nil + } + } + + var rawValue: Int { + switch self { + case .reasonUnknown: return 0 + case .reasonInitialization: return 1 + case .reasonPeriodic: return 2 + case .reasonSlowPeriodic: return 3 + case .reasonFastPeriodic: return 4 + case .reasonExpiration: return 5 + case .reasonFailureRecovery: return 6 + case .reasonNewAccount: return 7 + case .reasonChangedAccount: return 8 + case .reasonFeatureToggled: return 9 + case .reasonServerInitiated: return 10 + case .reasonAddressChange: return 11 + case .reasonSoftwareUpdate: return 12 + case .reasonManual: return 13 + case .reasonCustomKeyInvalidation: return 14 + case .reasonProximityPeriodic: return 15 + } + } + +} + +#if swift(>=4.2) + +extension Securegcm_InvocationReason: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +enum Securegcm_Type: SwiftProtobuf.Enum { + typealias RawValue = Int + case enrollment // = 0 + case tickle // = 1 + case txRequest // = 2 + case txReply // = 3 + case txSyncRequest // = 4 + case txSyncResponse // = 5 + case txPing // = 6 + case deviceInfoUpdate // = 7 + case txCancelRequest // = 8 + + /// DEPRECATED (can be re-used after Aug 2015) + case proximityauthPairing // = 10 + + /// The kind of identity assertion generated by a "GCM V1" device (i.e., + /// an Android phone that has registered with us a public and a symmetric + /// key) + case gcmv1IdentityAssertion // = 11 + + /// Device-to-device communications are protected by an unauthenticated + /// Diffie-Hellman exchange. The InitiatorHello message is simply the + /// initiator's public DH key, and is not encoded as a SecureMessage, so + /// it doesn't have a tag. + /// The ResponderHello message (which is sent by the responder + /// to the initiator), on the other hand, carries a payload that is protected + /// by the derived shared key. It also contains the responder's + /// public DH key. ResponderHelloAndPayload messages have the + /// DEVICE_TO_DEVICE_RESPONDER_HELLO tag. + case deviceToDeviceResponderHelloPayload // = 12 + + /// Device-to-device communications are protected by an unauthenticated + /// Diffie-Hellman exchange. Once the initiator and responder + /// agree on a shared key (through Diffie-Hellman), they will use messages + /// tagged with DEVICE_TO_DEVICE_MESSAGE to exchange data. + case deviceToDeviceMessage // = 13 + + /// Notification to let a device know it should contact a nearby device. + case deviceProximityCallback // = 14 + + /// Device-to-device communications are protected by an unauthenticated + /// Diffie-Hellman exchange. During device-to-device authentication, the first + /// message from initiator (the challenge) is signed and put into the payload + /// of the message sent back to the initiator. + case unlockKeySignedChallenge // = 15 + + /// Specialty (corp only) features + case loginNotification // = 101 + + init() { + self = .enrollment + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .enrollment + case 1: self = .tickle + case 2: self = .txRequest + case 3: self = .txReply + case 4: self = .txSyncRequest + case 5: self = .txSyncResponse + case 6: self = .txPing + case 7: self = .deviceInfoUpdate + case 8: self = .txCancelRequest + case 10: self = .proximityauthPairing + case 11: self = .gcmv1IdentityAssertion + case 12: self = .deviceToDeviceResponderHelloPayload + case 13: self = .deviceToDeviceMessage + case 14: self = .deviceProximityCallback + case 15: self = .unlockKeySignedChallenge + case 101: self = .loginNotification + default: return nil + } + } + + var rawValue: Int { + switch self { + case .enrollment: return 0 + case .tickle: return 1 + case .txRequest: return 2 + case .txReply: return 3 + case .txSyncRequest: return 4 + case .txSyncResponse: return 5 + case .txPing: return 6 + case .deviceInfoUpdate: return 7 + case .txCancelRequest: return 8 + case .proximityauthPairing: return 10 + case .gcmv1IdentityAssertion: return 11 + case .deviceToDeviceResponderHelloPayload: return 12 + case .deviceToDeviceMessage: return 13 + case .deviceProximityCallback: return 14 + case .unlockKeySignedChallenge: return 15 + case .loginNotification: return 101 + } + } + +} + +#if swift(>=4.2) + +extension Securegcm_Type: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// Message used only during enrollment +/// Field numbers should be kept in sync with DeviceInfo in: +/// java/com/google/security/cryptauth/backend/services/common/common.proto +struct Securegcm_GcmDeviceInfo { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// This field's name does not match the one in DeviceInfo for legacy reasons. + /// Consider using long_device_id and device_type instead when enrolling + /// non-android devices. + var androidDeviceID: UInt64 { + get {return _storage._androidDeviceID ?? 0} + set {_uniqueStorage()._androidDeviceID = newValue} + } + /// Returns true if `androidDeviceID` has been explicitly set. + var hasAndroidDeviceID: Bool {return _storage._androidDeviceID != nil} + /// Clears the value of `androidDeviceID`. Subsequent reads from it will return its default value. + mutating func clearAndroidDeviceID() {_uniqueStorage()._androidDeviceID = nil} + + /// Used for device_address of DeviceInfo field 2, but for GCM capable devices. + var gcmRegistrationID: Data { + get {return _storage._gcmRegistrationID ?? Data()} + set {_uniqueStorage()._gcmRegistrationID = newValue} + } + /// Returns true if `gcmRegistrationID` has been explicitly set. + var hasGcmRegistrationID: Bool {return _storage._gcmRegistrationID != nil} + /// Clears the value of `gcmRegistrationID`. Subsequent reads from it will return its default value. + mutating func clearGcmRegistrationID() {_uniqueStorage()._gcmRegistrationID = nil} + + /// Used for device_address of DeviceInfo field 2, but for iOS devices. + var apnRegistrationID: Data { + get {return _storage._apnRegistrationID ?? Data()} + set {_uniqueStorage()._apnRegistrationID = newValue} + } + /// Returns true if `apnRegistrationID` has been explicitly set. + var hasApnRegistrationID: Bool {return _storage._apnRegistrationID != nil} + /// Clears the value of `apnRegistrationID`. Subsequent reads from it will return its default value. + mutating func clearApnRegistrationID() {_uniqueStorage()._apnRegistrationID = nil} + + /// Does the user have notifications enabled for the given device address. + var notificationEnabled: Bool { + get {return _storage._notificationEnabled ?? true} + set {_uniqueStorage()._notificationEnabled = newValue} + } + /// Returns true if `notificationEnabled` has been explicitly set. + var hasNotificationEnabled: Bool {return _storage._notificationEnabled != nil} + /// Clears the value of `notificationEnabled`. Subsequent reads from it will return its default value. + mutating func clearNotificationEnabled() {_uniqueStorage()._notificationEnabled = nil} + + /// Used for device_address of DeviceInfo field 2, a Bluetooth Mac address for + /// the device (e.g., to be used with EasyUnlock) + var bluetoothMacAddress: String { + get {return _storage._bluetoothMacAddress ?? String()} + set {_uniqueStorage()._bluetoothMacAddress = newValue} + } + /// Returns true if `bluetoothMacAddress` has been explicitly set. + var hasBluetoothMacAddress: Bool {return _storage._bluetoothMacAddress != nil} + /// Clears the value of `bluetoothMacAddress`. Subsequent reads from it will return its default value. + mutating func clearBluetoothMacAddress() {_uniqueStorage()._bluetoothMacAddress = nil} + + /// SHA-256 hash of the device master key (from the key exchange). + /// Differs from DeviceInfo field 3, which contains the actual master key. + var deviceMasterKeyHash: Data { + get {return _storage._deviceMasterKeyHash ?? Data()} + set {_uniqueStorage()._deviceMasterKeyHash = newValue} + } + /// Returns true if `deviceMasterKeyHash` has been explicitly set. + var hasDeviceMasterKeyHash: Bool {return _storage._deviceMasterKeyHash != nil} + /// Clears the value of `deviceMasterKeyHash`. Subsequent reads from it will return its default value. + mutating func clearDeviceMasterKeyHash() {_uniqueStorage()._deviceMasterKeyHash = nil} + + /// A SecureMessage.EcP256PublicKey + var userPublicKey: Data { + get {return _storage._userPublicKey ?? Data()} + set {_uniqueStorage()._userPublicKey = newValue} + } + /// Returns true if `userPublicKey` has been explicitly set. + var hasUserPublicKey: Bool {return _storage._userPublicKey != nil} + /// Clears the value of `userPublicKey`. Subsequent reads from it will return its default value. + mutating func clearUserPublicKey() {_uniqueStorage()._userPublicKey = nil} + + /// device's model name + /// (e.g., an android.os.Build.MODEL or UIDevice.model) + var deviceModel: String { + get {return _storage._deviceModel ?? String()} + set {_uniqueStorage()._deviceModel = newValue} + } + /// Returns true if `deviceModel` has been explicitly set. + var hasDeviceModel: Bool {return _storage._deviceModel != nil} + /// Clears the value of `deviceModel`. Subsequent reads from it will return its default value. + mutating func clearDeviceModel() {_uniqueStorage()._deviceModel = nil} + + /// device's locale + var locale: String { + get {return _storage._locale ?? String()} + set {_uniqueStorage()._locale = newValue} + } + /// Returns true if `locale` has been explicitly set. + var hasLocale: Bool {return _storage._locale != nil} + /// Clears the value of `locale`. Subsequent reads from it will return its default value. + mutating func clearLocale() {_uniqueStorage()._locale = nil} + + /// The handle for user_public_key (and implicitly, a master key) + var keyHandle: Data { + get {return _storage._keyHandle ?? Data()} + set {_uniqueStorage()._keyHandle = newValue} + } + /// Returns true if `keyHandle` has been explicitly set. + var hasKeyHandle: Bool {return _storage._keyHandle != nil} + /// Clears the value of `keyHandle`. Subsequent reads from it will return its default value. + mutating func clearKeyHandle() {_uniqueStorage()._keyHandle = nil} + + /// The initial counter value for the device, sent by the device + var counter: Int64 { + get {return _storage._counter ?? 0} + set {_uniqueStorage()._counter = newValue} + } + /// Returns true if `counter` has been explicitly set. + var hasCounter: Bool {return _storage._counter != nil} + /// Clears the value of `counter`. Subsequent reads from it will return its default value. + mutating func clearCounter() {_uniqueStorage()._counter = nil} + + /// The Operating System version on the device + /// (e.g., an android.os.Build.DISPLAY or UIDevice.systemVersion) + var deviceOsVersion: String { + get {return _storage._deviceOsVersion ?? String()} + set {_uniqueStorage()._deviceOsVersion = newValue} + } + /// Returns true if `deviceOsVersion` has been explicitly set. + var hasDeviceOsVersion: Bool {return _storage._deviceOsVersion != nil} + /// Clears the value of `deviceOsVersion`. Subsequent reads from it will return its default value. + mutating func clearDeviceOsVersion() {_uniqueStorage()._deviceOsVersion = nil} + + /// The Operating System version number on the device + /// (e.g., an android.os.Build.VERSION.SDK_INT) + var deviceOsVersionCode: Int64 { + get {return _storage._deviceOsVersionCode ?? 0} + set {_uniqueStorage()._deviceOsVersionCode = newValue} + } + /// Returns true if `deviceOsVersionCode` has been explicitly set. + var hasDeviceOsVersionCode: Bool {return _storage._deviceOsVersionCode != nil} + /// Clears the value of `deviceOsVersionCode`. Subsequent reads from it will return its default value. + mutating func clearDeviceOsVersionCode() {_uniqueStorage()._deviceOsVersionCode = nil} + + /// The Operating System release on the device + /// (e.g., an android.os.Build.VERSION.RELEASE) + var deviceOsRelease: String { + get {return _storage._deviceOsRelease ?? String()} + set {_uniqueStorage()._deviceOsRelease = newValue} + } + /// Returns true if `deviceOsRelease` has been explicitly set. + var hasDeviceOsRelease: Bool {return _storage._deviceOsRelease != nil} + /// Clears the value of `deviceOsRelease`. Subsequent reads from it will return its default value. + mutating func clearDeviceOsRelease() {_uniqueStorage()._deviceOsRelease = nil} + + /// The Operating System codename on the device + /// (e.g., an android.os.Build.VERSION.CODENAME or UIDevice.systemName) + var deviceOsCodename: String { + get {return _storage._deviceOsCodename ?? String()} + set {_uniqueStorage()._deviceOsCodename = newValue} + } + /// Returns true if `deviceOsCodename` has been explicitly set. + var hasDeviceOsCodename: Bool {return _storage._deviceOsCodename != nil} + /// Clears the value of `deviceOsCodename`. Subsequent reads from it will return its default value. + mutating func clearDeviceOsCodename() {_uniqueStorage()._deviceOsCodename = nil} + + /// The software version running on the device + /// (e.g., Authenticator app version string) + var deviceSoftwareVersion: String { + get {return _storage._deviceSoftwareVersion ?? String()} + set {_uniqueStorage()._deviceSoftwareVersion = newValue} + } + /// Returns true if `deviceSoftwareVersion` has been explicitly set. + var hasDeviceSoftwareVersion: Bool {return _storage._deviceSoftwareVersion != nil} + /// Clears the value of `deviceSoftwareVersion`. Subsequent reads from it will return its default value. + mutating func clearDeviceSoftwareVersion() {_uniqueStorage()._deviceSoftwareVersion = nil} + + /// The software version number running on the device + /// (e.g., Authenticator app version code) + var deviceSoftwareVersionCode: Int64 { + get {return _storage._deviceSoftwareVersionCode ?? 0} + set {_uniqueStorage()._deviceSoftwareVersionCode = newValue} + } + /// Returns true if `deviceSoftwareVersionCode` has been explicitly set. + var hasDeviceSoftwareVersionCode: Bool {return _storage._deviceSoftwareVersionCode != nil} + /// Clears the value of `deviceSoftwareVersionCode`. Subsequent reads from it will return its default value. + mutating func clearDeviceSoftwareVersionCode() {_uniqueStorage()._deviceSoftwareVersionCode = nil} + + /// Software package information if applicable + /// (e.g., com.google.android.apps.authenticator2) + var deviceSoftwarePackage: String { + get {return _storage._deviceSoftwarePackage ?? String()} + set {_uniqueStorage()._deviceSoftwarePackage = newValue} + } + /// Returns true if `deviceSoftwarePackage` has been explicitly set. + var hasDeviceSoftwarePackage: Bool {return _storage._deviceSoftwarePackage != nil} + /// Clears the value of `deviceSoftwarePackage`. Subsequent reads from it will return its default value. + mutating func clearDeviceSoftwarePackage() {_uniqueStorage()._deviceSoftwarePackage = nil} + + /// Size of the display in thousandths of an inch (e.g., 7000 mils = 7 in) + var deviceDisplayDiagonalMils: Int32 { + get {return _storage._deviceDisplayDiagonalMils ?? 0} + set {_uniqueStorage()._deviceDisplayDiagonalMils = newValue} + } + /// Returns true if `deviceDisplayDiagonalMils` has been explicitly set. + var hasDeviceDisplayDiagonalMils: Bool {return _storage._deviceDisplayDiagonalMils != nil} + /// Clears the value of `deviceDisplayDiagonalMils`. Subsequent reads from it will return its default value. + mutating func clearDeviceDisplayDiagonalMils() {_uniqueStorage()._deviceDisplayDiagonalMils = nil} + + /// For Authzen capable devices, their Authzen protocol version + var deviceAuthzenVersion: Int32 { + get {return _storage._deviceAuthzenVersion ?? 0} + set {_uniqueStorage()._deviceAuthzenVersion = newValue} + } + /// Returns true if `deviceAuthzenVersion` has been explicitly set. + var hasDeviceAuthzenVersion: Bool {return _storage._deviceAuthzenVersion != nil} + /// Clears the value of `deviceAuthzenVersion`. Subsequent reads from it will return its default value. + mutating func clearDeviceAuthzenVersion() {_uniqueStorage()._deviceAuthzenVersion = nil} + + /// Not all devices have device identifiers that fit in 64 bits. + var longDeviceID: Data { + get {return _storage._longDeviceID ?? Data()} + set {_uniqueStorage()._longDeviceID = newValue} + } + /// Returns true if `longDeviceID` has been explicitly set. + var hasLongDeviceID: Bool {return _storage._longDeviceID != nil} + /// Clears the value of `longDeviceID`. Subsequent reads from it will return its default value. + mutating func clearLongDeviceID() {_uniqueStorage()._longDeviceID = nil} + + /// The device manufacturer name + /// (e.g., android.os.Build.MANUFACTURER) + var deviceManufacturer: String { + get {return _storage._deviceManufacturer ?? String()} + set {_uniqueStorage()._deviceManufacturer = newValue} + } + /// Returns true if `deviceManufacturer` has been explicitly set. + var hasDeviceManufacturer: Bool {return _storage._deviceManufacturer != nil} + /// Clears the value of `deviceManufacturer`. Subsequent reads from it will return its default value. + mutating func clearDeviceManufacturer() {_uniqueStorage()._deviceManufacturer = nil} + + /// Used to indicate which type of device this is. + var deviceType: Securegcm_DeviceType { + get {return _storage._deviceType ?? .android} + set {_uniqueStorage()._deviceType = newValue} + } + /// Returns true if `deviceType` has been explicitly set. + var hasDeviceType: Bool {return _storage._deviceType != nil} + /// Clears the value of `deviceType`. Subsequent reads from it will return its default value. + mutating func clearDeviceType() {_uniqueStorage()._deviceType = nil} + + /// Is this device using a secure screenlock (e.g., pattern or pin unlock) + var usingSecureScreenlock: Bool { + get {return _storage._usingSecureScreenlock ?? false} + set {_uniqueStorage()._usingSecureScreenlock = newValue} + } + /// Returns true if `usingSecureScreenlock` has been explicitly set. + var hasUsingSecureScreenlock: Bool {return _storage._usingSecureScreenlock != nil} + /// Clears the value of `usingSecureScreenlock`. Subsequent reads from it will return its default value. + mutating func clearUsingSecureScreenlock() {_uniqueStorage()._usingSecureScreenlock = nil} + + /// Is auto-unlocking the screenlock (e.g., when at "home") supported? + var autoUnlockScreenlockSupported: Bool { + get {return _storage._autoUnlockScreenlockSupported ?? false} + set {_uniqueStorage()._autoUnlockScreenlockSupported = newValue} + } + /// Returns true if `autoUnlockScreenlockSupported` has been explicitly set. + var hasAutoUnlockScreenlockSupported: Bool {return _storage._autoUnlockScreenlockSupported != nil} + /// Clears the value of `autoUnlockScreenlockSupported`. Subsequent reads from it will return its default value. + mutating func clearAutoUnlockScreenlockSupported() {_uniqueStorage()._autoUnlockScreenlockSupported = nil} + + /// Is auto-unlocking the screenlock (e.g., when at "home") enabled? + var autoUnlockScreenlockEnabled: Bool { + get {return _storage._autoUnlockScreenlockEnabled ?? false} + set {_uniqueStorage()._autoUnlockScreenlockEnabled = newValue} + } + /// Returns true if `autoUnlockScreenlockEnabled` has been explicitly set. + var hasAutoUnlockScreenlockEnabled: Bool {return _storage._autoUnlockScreenlockEnabled != nil} + /// Clears the value of `autoUnlockScreenlockEnabled`. Subsequent reads from it will return its default value. + mutating func clearAutoUnlockScreenlockEnabled() {_uniqueStorage()._autoUnlockScreenlockEnabled = nil} + + /// Does the device have a Bluetooth (classic) radio? + var bluetoothRadioSupported: Bool { + get {return _storage._bluetoothRadioSupported ?? false} + set {_uniqueStorage()._bluetoothRadioSupported = newValue} + } + /// Returns true if `bluetoothRadioSupported` has been explicitly set. + var hasBluetoothRadioSupported: Bool {return _storage._bluetoothRadioSupported != nil} + /// Clears the value of `bluetoothRadioSupported`. Subsequent reads from it will return its default value. + mutating func clearBluetoothRadioSupported() {_uniqueStorage()._bluetoothRadioSupported = nil} + + /// Is the Bluetooth (classic) radio on? + var bluetoothRadioEnabled: Bool { + get {return _storage._bluetoothRadioEnabled ?? false} + set {_uniqueStorage()._bluetoothRadioEnabled = newValue} + } + /// Returns true if `bluetoothRadioEnabled` has been explicitly set. + var hasBluetoothRadioEnabled: Bool {return _storage._bluetoothRadioEnabled != nil} + /// Clears the value of `bluetoothRadioEnabled`. Subsequent reads from it will return its default value. + mutating func clearBluetoothRadioEnabled() {_uniqueStorage()._bluetoothRadioEnabled = nil} + + /// Does the device hardware support a mobile data connection? + var mobileDataSupported: Bool { + get {return _storage._mobileDataSupported ?? false} + set {_uniqueStorage()._mobileDataSupported = newValue} + } + /// Returns true if `mobileDataSupported` has been explicitly set. + var hasMobileDataSupported: Bool {return _storage._mobileDataSupported != nil} + /// Clears the value of `mobileDataSupported`. Subsequent reads from it will return its default value. + mutating func clearMobileDataSupported() {_uniqueStorage()._mobileDataSupported = nil} + + /// Does the device support tethering? + var tetheringSupported: Bool { + get {return _storage._tetheringSupported ?? false} + set {_uniqueStorage()._tetheringSupported = newValue} + } + /// Returns true if `tetheringSupported` has been explicitly set. + var hasTetheringSupported: Bool {return _storage._tetheringSupported != nil} + /// Clears the value of `tetheringSupported`. Subsequent reads from it will return its default value. + mutating func clearTetheringSupported() {_uniqueStorage()._tetheringSupported = nil} + + /// Does the device have a BLE radio? + var bleRadioSupported: Bool { + get {return _storage._bleRadioSupported ?? false} + set {_uniqueStorage()._bleRadioSupported = newValue} + } + /// Returns true if `bleRadioSupported` has been explicitly set. + var hasBleRadioSupported: Bool {return _storage._bleRadioSupported != nil} + /// Clears the value of `bleRadioSupported`. Subsequent reads from it will return its default value. + mutating func clearBleRadioSupported() {_uniqueStorage()._bleRadioSupported = nil} + + /// Is the device a "Pixel Experience" Android device? + var pixelExperience: Bool { + get {return _storage._pixelExperience ?? false} + set {_uniqueStorage()._pixelExperience = newValue} + } + /// Returns true if `pixelExperience` has been explicitly set. + var hasPixelExperience: Bool {return _storage._pixelExperience != nil} + /// Clears the value of `pixelExperience`. Subsequent reads from it will return its default value. + mutating func clearPixelExperience() {_uniqueStorage()._pixelExperience = nil} + + /// Is the device running in the ARC++ container on a chromebook? + var arcPlusPlus: Bool { + get {return _storage._arcPlusPlus ?? false} + set {_uniqueStorage()._arcPlusPlus = newValue} + } + /// Returns true if `arcPlusPlus` has been explicitly set. + var hasArcPlusPlus: Bool {return _storage._arcPlusPlus != nil} + /// Clears the value of `arcPlusPlus`. Subsequent reads from it will return its default value. + mutating func clearArcPlusPlus() {_uniqueStorage()._arcPlusPlus = nil} + + /// Is the value set in |using_secure_screenlock| reliable? On some Android + /// devices, the platform API to get the screenlock state is not trustworthy. + /// See b/32212161. + var isScreenlockStateFlaky: Bool { + get {return _storage._isScreenlockStateFlaky ?? false} + set {_uniqueStorage()._isScreenlockStateFlaky = newValue} + } + /// Returns true if `isScreenlockStateFlaky` has been explicitly set. + var hasIsScreenlockStateFlaky: Bool {return _storage._isScreenlockStateFlaky != nil} + /// Clears the value of `isScreenlockStateFlaky`. Subsequent reads from it will return its default value. + mutating func clearIsScreenlockStateFlaky() {_uniqueStorage()._isScreenlockStateFlaky = nil} + + /// A list of multi-device software features supported by the device. + var supportedSoftwareFeatures: [Securegcm_SoftwareFeature] { + get {return _storage._supportedSoftwareFeatures} + set {_uniqueStorage()._supportedSoftwareFeatures = newValue} + } + + /// A list of multi-device software features currently enabled (active) on the + /// device. + var enabledSoftwareFeatures: [Securegcm_SoftwareFeature] { + get {return _storage._enabledSoftwareFeatures} + set {_uniqueStorage()._enabledSoftwareFeatures = newValue} + } + + /// The enrollment session id this is sent with + var enrollmentSessionID: Data { + get {return _storage._enrollmentSessionID ?? Data()} + set {_uniqueStorage()._enrollmentSessionID = newValue} + } + /// Returns true if `enrollmentSessionID` has been explicitly set. + var hasEnrollmentSessionID: Bool {return _storage._enrollmentSessionID != nil} + /// Clears the value of `enrollmentSessionID`. Subsequent reads from it will return its default value. + mutating func clearEnrollmentSessionID() {_uniqueStorage()._enrollmentSessionID = nil} + + /// A copy of the user's OAuth token + var oauthToken: String { + get {return _storage._oauthToken ?? String()} + set {_uniqueStorage()._oauthToken = newValue} + } + /// Returns true if `oauthToken` has been explicitly set. + var hasOauthToken: Bool {return _storage._oauthToken != nil} + /// Clears the value of `oauthToken`. Subsequent reads from it will return its default value. + mutating func clearOauthToken() {_uniqueStorage()._oauthToken = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _storage = _StorageClass.defaultInstance +} + +struct Securegcm_GcmMetadata { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var type: Securegcm_Type { + get {return _type ?? .enrollment} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + + var version: Int32 { + get {return _version ?? 0} + set {_version = newValue} + } + /// Returns true if `version` has been explicitly set. + var hasVersion: Bool {return self._version != nil} + /// Clears the value of `version`. Subsequent reads from it will return its default value. + mutating func clearVersion() {self._version = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _type: Securegcm_Type? = nil + fileprivate var _version: Int32? = nil +} + +struct Securegcm_Tickle { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Time after which this tickle should expire + var expiryTime: UInt64 { + get {return _expiryTime ?? 0} + set {_expiryTime = newValue} + } + /// Returns true if `expiryTime` has been explicitly set. + var hasExpiryTime: Bool {return self._expiryTime != nil} + /// Clears the value of `expiryTime`. Subsequent reads from it will return its default value. + mutating func clearExpiryTime() {self._expiryTime = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _expiryTime: UInt64? = nil +} + +struct Securegcm_LoginNotificationInfo { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Time at which the server received the login notification request. + var creationTime: UInt64 { + get {return _creationTime ?? 0} + set {_creationTime = newValue} + } + /// Returns true if `creationTime` has been explicitly set. + var hasCreationTime: Bool {return self._creationTime != nil} + /// Clears the value of `creationTime`. Subsequent reads from it will return its default value. + mutating func clearCreationTime() {self._creationTime = nil} + + /// Must correspond to user_id in LoginNotificationRequest, if set. + var email: String { + get {return _email ?? String()} + set {_email = newValue} + } + /// Returns true if `email` has been explicitly set. + var hasEmail: Bool {return self._email != nil} + /// Clears the value of `email`. Subsequent reads from it will return its default value. + mutating func clearEmail() {self._email = nil} + + /// Host where the user's credentials were used to login, if meaningful. + var host: String { + get {return _host ?? String()} + set {_host = newValue} + } + /// Returns true if `host` has been explicitly set. + var hasHost: Bool {return self._host != nil} + /// Clears the value of `host`. Subsequent reads from it will return its default value. + mutating func clearHost() {self._host = nil} + + /// Location from where the user's credentials were used, if meaningful. + var source: String { + get {return _source ?? String()} + set {_source = newValue} + } + /// Returns true if `source` has been explicitly set. + var hasSource: Bool {return self._source != nil} + /// Clears the value of `source`. Subsequent reads from it will return its default value. + mutating func clearSource() {self._source = nil} + + /// Type of login, e.g. ssh, gnome-screensaver, or web. + var eventType: String { + get {return _eventType ?? String()} + set {_eventType = newValue} + } + /// Returns true if `eventType` has been explicitly set. + var hasEventType: Bool {return self._eventType != nil} + /// Clears the value of `eventType`. Subsequent reads from it will return its default value. + mutating func clearEventType() {self._eventType = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _creationTime: UInt64? = nil + fileprivate var _email: String? = nil + fileprivate var _host: String? = nil + fileprivate var _source: String? = nil + fileprivate var _eventType: String? = nil +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Securegcm_AppleDeviceDiagonalMils: @unchecked Sendable {} +extension Securegcm_DeviceType: @unchecked Sendable {} +extension Securegcm_SoftwareFeature: @unchecked Sendable {} +extension Securegcm_InvocationReason: @unchecked Sendable {} +extension Securegcm_Type: @unchecked Sendable {} +extension Securegcm_GcmDeviceInfo: @unchecked Sendable {} +extension Securegcm_GcmMetadata: @unchecked Sendable {} +extension Securegcm_Tickle: @unchecked Sendable {} +extension Securegcm_LoginNotificationInfo: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "securegcm" + +extension Securegcm_AppleDeviceDiagonalMils: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 4000: .same(proto: "APPLE_PHONE"), + 7900: .same(proto: "APPLE_PAD"), + ] +} + +extension Securegcm_DeviceType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "ANDROID"), + 2: .same(proto: "CHROME"), + 3: .same(proto: "IOS"), + 4: .same(proto: "BROWSER"), + 5: .same(proto: "OSX"), + ] +} + +extension Securegcm_SoftwareFeature: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_FEATURE"), + 1: .same(proto: "BETTER_TOGETHER_HOST"), + 2: .same(proto: "BETTER_TOGETHER_CLIENT"), + 3: .same(proto: "EASY_UNLOCK_HOST"), + 4: .same(proto: "EASY_UNLOCK_CLIENT"), + 5: .same(proto: "MAGIC_TETHER_HOST"), + 6: .same(proto: "MAGIC_TETHER_CLIENT"), + 7: .same(proto: "SMS_CONNECT_HOST"), + 8: .same(proto: "SMS_CONNECT_CLIENT"), + ] +} + +extension Securegcm_InvocationReason: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "REASON_UNKNOWN"), + 1: .same(proto: "REASON_INITIALIZATION"), + 2: .same(proto: "REASON_PERIODIC"), + 3: .same(proto: "REASON_SLOW_PERIODIC"), + 4: .same(proto: "REASON_FAST_PERIODIC"), + 5: .same(proto: "REASON_EXPIRATION"), + 6: .same(proto: "REASON_FAILURE_RECOVERY"), + 7: .same(proto: "REASON_NEW_ACCOUNT"), + 8: .same(proto: "REASON_CHANGED_ACCOUNT"), + 9: .same(proto: "REASON_FEATURE_TOGGLED"), + 10: .same(proto: "REASON_SERVER_INITIATED"), + 11: .same(proto: "REASON_ADDRESS_CHANGE"), + 12: .same(proto: "REASON_SOFTWARE_UPDATE"), + 13: .same(proto: "REASON_MANUAL"), + 14: .same(proto: "REASON_CUSTOM_KEY_INVALIDATION"), + 15: .same(proto: "REASON_PROXIMITY_PERIODIC"), + ] +} + +extension Securegcm_Type: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "ENROLLMENT"), + 1: .same(proto: "TICKLE"), + 2: .same(proto: "TX_REQUEST"), + 3: .same(proto: "TX_REPLY"), + 4: .same(proto: "TX_SYNC_REQUEST"), + 5: .same(proto: "TX_SYNC_RESPONSE"), + 6: .same(proto: "TX_PING"), + 7: .same(proto: "DEVICE_INFO_UPDATE"), + 8: .same(proto: "TX_CANCEL_REQUEST"), + 10: .same(proto: "PROXIMITYAUTH_PAIRING"), + 11: .same(proto: "GCMV1_IDENTITY_ASSERTION"), + 12: .same(proto: "DEVICE_TO_DEVICE_RESPONDER_HELLO_PAYLOAD"), + 13: .same(proto: "DEVICE_TO_DEVICE_MESSAGE"), + 14: .same(proto: "DEVICE_PROXIMITY_CALLBACK"), + 15: .same(proto: "UNLOCK_KEY_SIGNED_CHALLENGE"), + 101: .same(proto: "LOGIN_NOTIFICATION"), + ] +} + +extension Securegcm_GcmDeviceInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".GcmDeviceInfo" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "android_device_id"), + 102: .standard(proto: "gcm_registration_id"), + 202: .standard(proto: "apn_registration_id"), + 203: .standard(proto: "notification_enabled"), + 302: .standard(proto: "bluetooth_mac_address"), + 103: .standard(proto: "device_master_key_hash"), + 4: .standard(proto: "user_public_key"), + 7: .standard(proto: "device_model"), + 8: .same(proto: "locale"), + 9: .standard(proto: "key_handle"), + 12: .same(proto: "counter"), + 13: .standard(proto: "device_os_version"), + 14: .standard(proto: "device_os_version_code"), + 15: .standard(proto: "device_os_release"), + 16: .standard(proto: "device_os_codename"), + 17: .standard(proto: "device_software_version"), + 18: .standard(proto: "device_software_version_code"), + 19: .standard(proto: "device_software_package"), + 22: .standard(proto: "device_display_diagonal_mils"), + 24: .standard(proto: "device_authzen_version"), + 29: .standard(proto: "long_device_id"), + 31: .standard(proto: "device_manufacturer"), + 32: .standard(proto: "device_type"), + 400: .standard(proto: "using_secure_screenlock"), + 401: .standard(proto: "auto_unlock_screenlock_supported"), + 402: .standard(proto: "auto_unlock_screenlock_enabled"), + 403: .standard(proto: "bluetooth_radio_supported"), + 404: .standard(proto: "bluetooth_radio_enabled"), + 405: .standard(proto: "mobile_data_supported"), + 406: .standard(proto: "tethering_supported"), + 407: .standard(proto: "ble_radio_supported"), + 408: .standard(proto: "pixel_experience"), + 409: .standard(proto: "arc_plus_plus"), + 410: .standard(proto: "is_screenlock_state_flaky"), + 411: .standard(proto: "supported_software_features"), + 412: .standard(proto: "enabled_software_features"), + 1000: .standard(proto: "enrollment_session_id"), + 1001: .standard(proto: "oauth_token"), + ] + + fileprivate class _StorageClass { + var _androidDeviceID: UInt64? = nil + var _gcmRegistrationID: Data? = nil + var _apnRegistrationID: Data? = nil + var _notificationEnabled: Bool? = nil + var _bluetoothMacAddress: String? = nil + var _deviceMasterKeyHash: Data? = nil + var _userPublicKey: Data? = nil + var _deviceModel: String? = nil + var _locale: String? = nil + var _keyHandle: Data? = nil + var _counter: Int64? = nil + var _deviceOsVersion: String? = nil + var _deviceOsVersionCode: Int64? = nil + var _deviceOsRelease: String? = nil + var _deviceOsCodename: String? = nil + var _deviceSoftwareVersion: String? = nil + var _deviceSoftwareVersionCode: Int64? = nil + var _deviceSoftwarePackage: String? = nil + var _deviceDisplayDiagonalMils: Int32? = nil + var _deviceAuthzenVersion: Int32? = nil + var _longDeviceID: Data? = nil + var _deviceManufacturer: String? = nil + var _deviceType: Securegcm_DeviceType? = nil + var _usingSecureScreenlock: Bool? = nil + var _autoUnlockScreenlockSupported: Bool? = nil + var _autoUnlockScreenlockEnabled: Bool? = nil + var _bluetoothRadioSupported: Bool? = nil + var _bluetoothRadioEnabled: Bool? = nil + var _mobileDataSupported: Bool? = nil + var _tetheringSupported: Bool? = nil + var _bleRadioSupported: Bool? = nil + var _pixelExperience: Bool? = nil + var _arcPlusPlus: Bool? = nil + var _isScreenlockStateFlaky: Bool? = nil + var _supportedSoftwareFeatures: [Securegcm_SoftwareFeature] = [] + var _enabledSoftwareFeatures: [Securegcm_SoftwareFeature] = [] + var _enrollmentSessionID: Data? = nil + var _oauthToken: String? = nil + + static let defaultInstance = _StorageClass() + + private init() {} + + init(copying source: _StorageClass) { + _androidDeviceID = source._androidDeviceID + _gcmRegistrationID = source._gcmRegistrationID + _apnRegistrationID = source._apnRegistrationID + _notificationEnabled = source._notificationEnabled + _bluetoothMacAddress = source._bluetoothMacAddress + _deviceMasterKeyHash = source._deviceMasterKeyHash + _userPublicKey = source._userPublicKey + _deviceModel = source._deviceModel + _locale = source._locale + _keyHandle = source._keyHandle + _counter = source._counter + _deviceOsVersion = source._deviceOsVersion + _deviceOsVersionCode = source._deviceOsVersionCode + _deviceOsRelease = source._deviceOsRelease + _deviceOsCodename = source._deviceOsCodename + _deviceSoftwareVersion = source._deviceSoftwareVersion + _deviceSoftwareVersionCode = source._deviceSoftwareVersionCode + _deviceSoftwarePackage = source._deviceSoftwarePackage + _deviceDisplayDiagonalMils = source._deviceDisplayDiagonalMils + _deviceAuthzenVersion = source._deviceAuthzenVersion + _longDeviceID = source._longDeviceID + _deviceManufacturer = source._deviceManufacturer + _deviceType = source._deviceType + _usingSecureScreenlock = source._usingSecureScreenlock + _autoUnlockScreenlockSupported = source._autoUnlockScreenlockSupported + _autoUnlockScreenlockEnabled = source._autoUnlockScreenlockEnabled + _bluetoothRadioSupported = source._bluetoothRadioSupported + _bluetoothRadioEnabled = source._bluetoothRadioEnabled + _mobileDataSupported = source._mobileDataSupported + _tetheringSupported = source._tetheringSupported + _bleRadioSupported = source._bleRadioSupported + _pixelExperience = source._pixelExperience + _arcPlusPlus = source._arcPlusPlus + _isScreenlockStateFlaky = source._isScreenlockStateFlaky + _supportedSoftwareFeatures = source._supportedSoftwareFeatures + _enabledSoftwareFeatures = source._enabledSoftwareFeatures + _enrollmentSessionID = source._enrollmentSessionID + _oauthToken = source._oauthToken + } + } + + fileprivate mutating func _uniqueStorage() -> _StorageClass { + if !isKnownUniquelyReferenced(&_storage) { + _storage = _StorageClass(copying: _storage) + } + return _storage + } + + public var isInitialized: Bool { + return withExtendedLifetime(_storage) { (_storage: _StorageClass) in + if _storage._userPublicKey == nil {return false} + return true + } + } + + mutating func decodeMessage(decoder: inout D) throws { + _ = _uniqueStorage() + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularFixed64Field(value: &_storage._androidDeviceID) }() + case 4: try { try decoder.decodeSingularBytesField(value: &_storage._userPublicKey) }() + case 7: try { try decoder.decodeSingularStringField(value: &_storage._deviceModel) }() + case 8: try { try decoder.decodeSingularStringField(value: &_storage._locale) }() + case 9: try { try decoder.decodeSingularBytesField(value: &_storage._keyHandle) }() + case 12: try { try decoder.decodeSingularInt64Field(value: &_storage._counter) }() + case 13: try { try decoder.decodeSingularStringField(value: &_storage._deviceOsVersion) }() + case 14: try { try decoder.decodeSingularInt64Field(value: &_storage._deviceOsVersionCode) }() + case 15: try { try decoder.decodeSingularStringField(value: &_storage._deviceOsRelease) }() + case 16: try { try decoder.decodeSingularStringField(value: &_storage._deviceOsCodename) }() + case 17: try { try decoder.decodeSingularStringField(value: &_storage._deviceSoftwareVersion) }() + case 18: try { try decoder.decodeSingularInt64Field(value: &_storage._deviceSoftwareVersionCode) }() + case 19: try { try decoder.decodeSingularStringField(value: &_storage._deviceSoftwarePackage) }() + case 22: try { try decoder.decodeSingularInt32Field(value: &_storage._deviceDisplayDiagonalMils) }() + case 24: try { try decoder.decodeSingularInt32Field(value: &_storage._deviceAuthzenVersion) }() + case 29: try { try decoder.decodeSingularBytesField(value: &_storage._longDeviceID) }() + case 31: try { try decoder.decodeSingularStringField(value: &_storage._deviceManufacturer) }() + case 32: try { try decoder.decodeSingularEnumField(value: &_storage._deviceType) }() + case 102: try { try decoder.decodeSingularBytesField(value: &_storage._gcmRegistrationID) }() + case 103: try { try decoder.decodeSingularBytesField(value: &_storage._deviceMasterKeyHash) }() + case 202: try { try decoder.decodeSingularBytesField(value: &_storage._apnRegistrationID) }() + case 203: try { try decoder.decodeSingularBoolField(value: &_storage._notificationEnabled) }() + case 302: try { try decoder.decodeSingularStringField(value: &_storage._bluetoothMacAddress) }() + case 400: try { try decoder.decodeSingularBoolField(value: &_storage._usingSecureScreenlock) }() + case 401: try { try decoder.decodeSingularBoolField(value: &_storage._autoUnlockScreenlockSupported) }() + case 402: try { try decoder.decodeSingularBoolField(value: &_storage._autoUnlockScreenlockEnabled) }() + case 403: try { try decoder.decodeSingularBoolField(value: &_storage._bluetoothRadioSupported) }() + case 404: try { try decoder.decodeSingularBoolField(value: &_storage._bluetoothRadioEnabled) }() + case 405: try { try decoder.decodeSingularBoolField(value: &_storage._mobileDataSupported) }() + case 406: try { try decoder.decodeSingularBoolField(value: &_storage._tetheringSupported) }() + case 407: try { try decoder.decodeSingularBoolField(value: &_storage._bleRadioSupported) }() + case 408: try { try decoder.decodeSingularBoolField(value: &_storage._pixelExperience) }() + case 409: try { try decoder.decodeSingularBoolField(value: &_storage._arcPlusPlus) }() + case 410: try { try decoder.decodeSingularBoolField(value: &_storage._isScreenlockStateFlaky) }() + case 411: try { try decoder.decodeRepeatedEnumField(value: &_storage._supportedSoftwareFeatures) }() + case 412: try { try decoder.decodeRepeatedEnumField(value: &_storage._enabledSoftwareFeatures) }() + case 1000: try { try decoder.decodeSingularBytesField(value: &_storage._enrollmentSessionID) }() + case 1001: try { try decoder.decodeSingularStringField(value: &_storage._oauthToken) }() + default: break + } + } + } + } + + func traverse(visitor: inout V) throws { + try withExtendedLifetime(_storage) { (_storage: _StorageClass) in + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = _storage._androidDeviceID { + try visitor.visitSingularFixed64Field(value: v, fieldNumber: 1) + } }() + try { if let v = _storage._userPublicKey { + try visitor.visitSingularBytesField(value: v, fieldNumber: 4) + } }() + try { if let v = _storage._deviceModel { + try visitor.visitSingularStringField(value: v, fieldNumber: 7) + } }() + try { if let v = _storage._locale { + try visitor.visitSingularStringField(value: v, fieldNumber: 8) + } }() + try { if let v = _storage._keyHandle { + try visitor.visitSingularBytesField(value: v, fieldNumber: 9) + } }() + try { if let v = _storage._counter { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 12) + } }() + try { if let v = _storage._deviceOsVersion { + try visitor.visitSingularStringField(value: v, fieldNumber: 13) + } }() + try { if let v = _storage._deviceOsVersionCode { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 14) + } }() + try { if let v = _storage._deviceOsRelease { + try visitor.visitSingularStringField(value: v, fieldNumber: 15) + } }() + try { if let v = _storage._deviceOsCodename { + try visitor.visitSingularStringField(value: v, fieldNumber: 16) + } }() + try { if let v = _storage._deviceSoftwareVersion { + try visitor.visitSingularStringField(value: v, fieldNumber: 17) + } }() + try { if let v = _storage._deviceSoftwareVersionCode { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 18) + } }() + try { if let v = _storage._deviceSoftwarePackage { + try visitor.visitSingularStringField(value: v, fieldNumber: 19) + } }() + try { if let v = _storage._deviceDisplayDiagonalMils { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 22) + } }() + try { if let v = _storage._deviceAuthzenVersion { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 24) + } }() + try { if let v = _storage._longDeviceID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 29) + } }() + try { if let v = _storage._deviceManufacturer { + try visitor.visitSingularStringField(value: v, fieldNumber: 31) + } }() + try { if let v = _storage._deviceType { + try visitor.visitSingularEnumField(value: v, fieldNumber: 32) + } }() + try { if let v = _storage._gcmRegistrationID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 102) + } }() + try { if let v = _storage._deviceMasterKeyHash { + try visitor.visitSingularBytesField(value: v, fieldNumber: 103) + } }() + try { if let v = _storage._apnRegistrationID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 202) + } }() + try { if let v = _storage._notificationEnabled { + try visitor.visitSingularBoolField(value: v, fieldNumber: 203) + } }() + try { if let v = _storage._bluetoothMacAddress { + try visitor.visitSingularStringField(value: v, fieldNumber: 302) + } }() + try { if let v = _storage._usingSecureScreenlock { + try visitor.visitSingularBoolField(value: v, fieldNumber: 400) + } }() + try { if let v = _storage._autoUnlockScreenlockSupported { + try visitor.visitSingularBoolField(value: v, fieldNumber: 401) + } }() + try { if let v = _storage._autoUnlockScreenlockEnabled { + try visitor.visitSingularBoolField(value: v, fieldNumber: 402) + } }() + try { if let v = _storage._bluetoothRadioSupported { + try visitor.visitSingularBoolField(value: v, fieldNumber: 403) + } }() + try { if let v = _storage._bluetoothRadioEnabled { + try visitor.visitSingularBoolField(value: v, fieldNumber: 404) + } }() + try { if let v = _storage._mobileDataSupported { + try visitor.visitSingularBoolField(value: v, fieldNumber: 405) + } }() + try { if let v = _storage._tetheringSupported { + try visitor.visitSingularBoolField(value: v, fieldNumber: 406) + } }() + try { if let v = _storage._bleRadioSupported { + try visitor.visitSingularBoolField(value: v, fieldNumber: 407) + } }() + try { if let v = _storage._pixelExperience { + try visitor.visitSingularBoolField(value: v, fieldNumber: 408) + } }() + try { if let v = _storage._arcPlusPlus { + try visitor.visitSingularBoolField(value: v, fieldNumber: 409) + } }() + try { if let v = _storage._isScreenlockStateFlaky { + try visitor.visitSingularBoolField(value: v, fieldNumber: 410) + } }() + if !_storage._supportedSoftwareFeatures.isEmpty { + try visitor.visitRepeatedEnumField(value: _storage._supportedSoftwareFeatures, fieldNumber: 411) + } + if !_storage._enabledSoftwareFeatures.isEmpty { + try visitor.visitRepeatedEnumField(value: _storage._enabledSoftwareFeatures, fieldNumber: 412) + } + try { if let v = _storage._enrollmentSessionID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1000) + } }() + try { if let v = _storage._oauthToken { + try visitor.visitSingularStringField(value: v, fieldNumber: 1001) + } }() + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_GcmDeviceInfo, rhs: Securegcm_GcmDeviceInfo) -> Bool { + if lhs._storage !== rhs._storage { + let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in + let _storage = _args.0 + let rhs_storage = _args.1 + if _storage._androidDeviceID != rhs_storage._androidDeviceID {return false} + if _storage._gcmRegistrationID != rhs_storage._gcmRegistrationID {return false} + if _storage._apnRegistrationID != rhs_storage._apnRegistrationID {return false} + if _storage._notificationEnabled != rhs_storage._notificationEnabled {return false} + if _storage._bluetoothMacAddress != rhs_storage._bluetoothMacAddress {return false} + if _storage._deviceMasterKeyHash != rhs_storage._deviceMasterKeyHash {return false} + if _storage._userPublicKey != rhs_storage._userPublicKey {return false} + if _storage._deviceModel != rhs_storage._deviceModel {return false} + if _storage._locale != rhs_storage._locale {return false} + if _storage._keyHandle != rhs_storage._keyHandle {return false} + if _storage._counter != rhs_storage._counter {return false} + if _storage._deviceOsVersion != rhs_storage._deviceOsVersion {return false} + if _storage._deviceOsVersionCode != rhs_storage._deviceOsVersionCode {return false} + if _storage._deviceOsRelease != rhs_storage._deviceOsRelease {return false} + if _storage._deviceOsCodename != rhs_storage._deviceOsCodename {return false} + if _storage._deviceSoftwareVersion != rhs_storage._deviceSoftwareVersion {return false} + if _storage._deviceSoftwareVersionCode != rhs_storage._deviceSoftwareVersionCode {return false} + if _storage._deviceSoftwarePackage != rhs_storage._deviceSoftwarePackage {return false} + if _storage._deviceDisplayDiagonalMils != rhs_storage._deviceDisplayDiagonalMils {return false} + if _storage._deviceAuthzenVersion != rhs_storage._deviceAuthzenVersion {return false} + if _storage._longDeviceID != rhs_storage._longDeviceID {return false} + if _storage._deviceManufacturer != rhs_storage._deviceManufacturer {return false} + if _storage._deviceType != rhs_storage._deviceType {return false} + if _storage._usingSecureScreenlock != rhs_storage._usingSecureScreenlock {return false} + if _storage._autoUnlockScreenlockSupported != rhs_storage._autoUnlockScreenlockSupported {return false} + if _storage._autoUnlockScreenlockEnabled != rhs_storage._autoUnlockScreenlockEnabled {return false} + if _storage._bluetoothRadioSupported != rhs_storage._bluetoothRadioSupported {return false} + if _storage._bluetoothRadioEnabled != rhs_storage._bluetoothRadioEnabled {return false} + if _storage._mobileDataSupported != rhs_storage._mobileDataSupported {return false} + if _storage._tetheringSupported != rhs_storage._tetheringSupported {return false} + if _storage._bleRadioSupported != rhs_storage._bleRadioSupported {return false} + if _storage._pixelExperience != rhs_storage._pixelExperience {return false} + if _storage._arcPlusPlus != rhs_storage._arcPlusPlus {return false} + if _storage._isScreenlockStateFlaky != rhs_storage._isScreenlockStateFlaky {return false} + if _storage._supportedSoftwareFeatures != rhs_storage._supportedSoftwareFeatures {return false} + if _storage._enabledSoftwareFeatures != rhs_storage._enabledSoftwareFeatures {return false} + if _storage._enrollmentSessionID != rhs_storage._enrollmentSessionID {return false} + if _storage._oauthToken != rhs_storage._oauthToken {return false} + return true + } + if !storagesAreEqual {return false} + } + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_GcmMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".GcmMetadata" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .same(proto: "version"), + ] + + public var isInitialized: Bool { + if self._type == nil {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._type) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self._version) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._version { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_GcmMetadata, rhs: Securegcm_GcmMetadata) -> Bool { + if lhs._type != rhs._type {return false} + if lhs._version != rhs._version {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_Tickle: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Tickle" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "expiry_time"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularFixed64Field(value: &self._expiryTime) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._expiryTime { + try visitor.visitSingularFixed64Field(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_Tickle, rhs: Securegcm_Tickle) -> Bool { + if lhs._expiryTime != rhs._expiryTime {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_LoginNotificationInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".LoginNotificationInfo" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 2: .standard(proto: "creation_time"), + 3: .same(proto: "email"), + 4: .same(proto: "host"), + 5: .same(proto: "source"), + 6: .standard(proto: "event_type"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 2: try { try decoder.decodeSingularFixed64Field(value: &self._creationTime) }() + case 3: try { try decoder.decodeSingularStringField(value: &self._email) }() + case 4: try { try decoder.decodeSingularStringField(value: &self._host) }() + case 5: try { try decoder.decodeSingularStringField(value: &self._source) }() + case 6: try { try decoder.decodeSingularStringField(value: &self._eventType) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._creationTime { + try visitor.visitSingularFixed64Field(value: v, fieldNumber: 2) + } }() + try { if let v = self._email { + try visitor.visitSingularStringField(value: v, fieldNumber: 3) + } }() + try { if let v = self._host { + try visitor.visitSingularStringField(value: v, fieldNumber: 4) + } }() + try { if let v = self._source { + try visitor.visitSingularStringField(value: v, fieldNumber: 5) + } }() + try { if let v = self._eventType { + try visitor.visitSingularStringField(value: v, fieldNumber: 6) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_LoginNotificationInfo, rhs: Securegcm_LoginNotificationInfo) -> Bool { + if lhs._creationTime != rhs._creationTime {return false} + if lhs._email != rhs._email {return false} + if lhs._host != rhs._host {return false} + if lhs._source != rhs._source {return false} + if lhs._eventType != rhs._eventType {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/NearDrop/Protobuf/securemessage.pb.swift b/NearDrop/Protobuf/securemessage.pb.swift new file mode 100644 index 0000000..eae8d01 --- /dev/null +++ b/NearDrop/Protobuf/securemessage.pb.swift @@ -0,0 +1,951 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: securemessage.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Proto definitions for SecureMessage format + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// Supported "signature" schemes (both symmetric key and public key based) +enum Securemessage_SigScheme: SwiftProtobuf.Enum { + typealias RawValue = Int + case hmacSha256 // = 1 + case ecdsaP256Sha256 // = 2 + + /// Not recommended -- use ECDSA_P256_SHA256 instead + case rsa2048Sha256 // = 3 + + init() { + self = .hmacSha256 + } + + init?(rawValue: Int) { + switch rawValue { + case 1: self = .hmacSha256 + case 2: self = .ecdsaP256Sha256 + case 3: self = .rsa2048Sha256 + default: return nil + } + } + + var rawValue: Int { + switch self { + case .hmacSha256: return 1 + case .ecdsaP256Sha256: return 2 + case .rsa2048Sha256: return 3 + } + } + +} + +#if swift(>=4.2) + +extension Securemessage_SigScheme: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// Supported encryption schemes +enum Securemessage_EncScheme: SwiftProtobuf.Enum { + typealias RawValue = Int + + /// No encryption + case none // = 1 + case aes256Cbc // = 2 + + init() { + self = .none + } + + init?(rawValue: Int) { + switch rawValue { + case 1: self = .none + case 2: self = .aes256Cbc + default: return nil + } + } + + var rawValue: Int { + switch self { + case .none: return 1 + case .aes256Cbc: return 2 + } + } + +} + +#if swift(>=4.2) + +extension Securemessage_EncScheme: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// A list of supported public key types +enum Securemessage_PublicKeyType: SwiftProtobuf.Enum { + typealias RawValue = Int + case ecP256 // = 1 + case rsa2048 // = 2 + + /// 2048-bit MODP group 14, from RFC 3526 + case dh2048Modp // = 3 + + init() { + self = .ecP256 + } + + init?(rawValue: Int) { + switch rawValue { + case 1: self = .ecP256 + case 2: self = .rsa2048 + case 3: self = .dh2048Modp + default: return nil + } + } + + var rawValue: Int { + switch self { + case .ecP256: return 1 + case .rsa2048: return 2 + case .dh2048Modp: return 3 + } + } + +} + +#if swift(>=4.2) + +extension Securemessage_PublicKeyType: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Securemessage_SecureMessage { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Must contain a HeaderAndBody message + var headerAndBody: Data { + get {return _headerAndBody ?? Data()} + set {_headerAndBody = newValue} + } + /// Returns true if `headerAndBody` has been explicitly set. + var hasHeaderAndBody: Bool {return self._headerAndBody != nil} + /// Clears the value of `headerAndBody`. Subsequent reads from it will return its default value. + mutating func clearHeaderAndBody() {self._headerAndBody = nil} + + /// Signature of header_and_body + var signature: Data { + get {return _signature ?? Data()} + set {_signature = newValue} + } + /// Returns true if `signature` has been explicitly set. + var hasSignature: Bool {return self._signature != nil} + /// Clears the value of `signature`. Subsequent reads from it will return its default value. + mutating func clearSignature() {self._signature = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _headerAndBody: Data? = nil + fileprivate var _signature: Data? = nil +} + +struct Securemessage_Header { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var signatureScheme: Securemessage_SigScheme { + get {return _signatureScheme ?? .hmacSha256} + set {_signatureScheme = newValue} + } + /// Returns true if `signatureScheme` has been explicitly set. + var hasSignatureScheme: Bool {return self._signatureScheme != nil} + /// Clears the value of `signatureScheme`. Subsequent reads from it will return its default value. + mutating func clearSignatureScheme() {self._signatureScheme = nil} + + var encryptionScheme: Securemessage_EncScheme { + get {return _encryptionScheme ?? .none} + set {_encryptionScheme = newValue} + } + /// Returns true if `encryptionScheme` has been explicitly set. + var hasEncryptionScheme: Bool {return self._encryptionScheme != nil} + /// Clears the value of `encryptionScheme`. Subsequent reads from it will return its default value. + mutating func clearEncryptionScheme() {self._encryptionScheme = nil} + + /// Identifies the verification key + var verificationKeyID: Data { + get {return _verificationKeyID ?? Data()} + set {_verificationKeyID = newValue} + } + /// Returns true if `verificationKeyID` has been explicitly set. + var hasVerificationKeyID: Bool {return self._verificationKeyID != nil} + /// Clears the value of `verificationKeyID`. Subsequent reads from it will return its default value. + mutating func clearVerificationKeyID() {self._verificationKeyID = nil} + + /// Identifies the decryption key + var decryptionKeyID: Data { + get {return _decryptionKeyID ?? Data()} + set {_decryptionKeyID = newValue} + } + /// Returns true if `decryptionKeyID` has been explicitly set. + var hasDecryptionKeyID: Bool {return self._decryptionKeyID != nil} + /// Clears the value of `decryptionKeyID`. Subsequent reads from it will return its default value. + mutating func clearDecryptionKeyID() {self._decryptionKeyID = nil} + + /// Encryption may use an IV + var iv: Data { + get {return _iv ?? Data()} + set {_iv = newValue} + } + /// Returns true if `iv` has been explicitly set. + var hasIv: Bool {return self._iv != nil} + /// Clears the value of `iv`. Subsequent reads from it will return its default value. + mutating func clearIv() {self._iv = nil} + + /// Arbitrary per-protocol public data, to be sent with the plain-text header + var publicMetadata: Data { + get {return _publicMetadata ?? Data()} + set {_publicMetadata = newValue} + } + /// Returns true if `publicMetadata` has been explicitly set. + var hasPublicMetadata: Bool {return self._publicMetadata != nil} + /// Clears the value of `publicMetadata`. Subsequent reads from it will return its default value. + mutating func clearPublicMetadata() {self._publicMetadata = nil} + + /// The length of some associated data this is not sent in this SecureMessage, + /// but which will be bound to the signature. + var associatedDataLength: UInt32 { + get {return _associatedDataLength ?? 0} + set {_associatedDataLength = newValue} + } + /// Returns true if `associatedDataLength` has been explicitly set. + var hasAssociatedDataLength: Bool {return self._associatedDataLength != nil} + /// Clears the value of `associatedDataLength`. Subsequent reads from it will return its default value. + mutating func clearAssociatedDataLength() {self._associatedDataLength = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _signatureScheme: Securemessage_SigScheme? = nil + fileprivate var _encryptionScheme: Securemessage_EncScheme? = nil + fileprivate var _verificationKeyID: Data? = nil + fileprivate var _decryptionKeyID: Data? = nil + fileprivate var _iv: Data? = nil + fileprivate var _publicMetadata: Data? = nil + fileprivate var _associatedDataLength: UInt32? = nil +} + +struct Securemessage_HeaderAndBody { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Public data about this message (to be bound in the signature) + var header: Securemessage_Header { + get {return _header ?? Securemessage_Header()} + set {_header = newValue} + } + /// Returns true if `header` has been explicitly set. + var hasHeader: Bool {return self._header != nil} + /// Clears the value of `header`. Subsequent reads from it will return its default value. + mutating func clearHeader() {self._header = nil} + + /// Payload data + var body: Data { + get {return _body ?? Data()} + set {_body = newValue} + } + /// Returns true if `body` has been explicitly set. + var hasBody: Bool {return self._body != nil} + /// Clears the value of `body`. Subsequent reads from it will return its default value. + mutating func clearBody() {self._body = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _header: Securemessage_Header? = nil + fileprivate var _body: Data? = nil +} + +/// Must be kept wire-format compatible with HeaderAndBody. Provides the +/// SecureMessage code with a consistent wire-format representation that +/// remains stable irrespective of protobuf implementation choices. This +/// low-level representation of a HeaderAndBody should not be used by +/// any code outside of the SecureMessage library implementation/tests. +struct Securemessage_HeaderAndBodyInternal { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// A raw (wire-format) byte encoding of a Header, suitable for hashing + var header: Data { + get {return _header ?? Data()} + set {_header = newValue} + } + /// Returns true if `header` has been explicitly set. + var hasHeader: Bool {return self._header != nil} + /// Clears the value of `header`. Subsequent reads from it will return its default value. + mutating func clearHeader() {self._header = nil} + + /// Payload data + var body: Data { + get {return _body ?? Data()} + set {_body = newValue} + } + /// Returns true if `body` has been explicitly set. + var hasBody: Bool {return self._body != nil} + /// Clears the value of `body`. Subsequent reads from it will return its default value. + mutating func clearBody() {self._body = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _header: Data? = nil + fileprivate var _body: Data? = nil +} + +/// A convenience proto for encoding NIST P-256 elliptic curve public keys +struct Securemessage_EcP256PublicKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// x and y are encoded in big-endian two's complement (slightly wasteful) + /// Client MUST verify (x,y) is a valid point on NIST P256 + var x: Data { + get {return _x ?? Data()} + set {_x = newValue} + } + /// Returns true if `x` has been explicitly set. + var hasX: Bool {return self._x != nil} + /// Clears the value of `x`. Subsequent reads from it will return its default value. + mutating func clearX() {self._x = nil} + + var y: Data { + get {return _y ?? Data()} + set {_y = newValue} + } + /// Returns true if `y` has been explicitly set. + var hasY: Bool {return self._y != nil} + /// Clears the value of `y`. Subsequent reads from it will return its default value. + mutating func clearY() {self._y = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _x: Data? = nil + fileprivate var _y: Data? = nil +} + +/// A convenience proto for encoding RSA public keys with small exponents +struct Securemessage_SimpleRsaPublicKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Encoded in big-endian two's complement + var n: Data { + get {return _n ?? Data()} + set {_n = newValue} + } + /// Returns true if `n` has been explicitly set. + var hasN: Bool {return self._n != nil} + /// Clears the value of `n`. Subsequent reads from it will return its default value. + mutating func clearN() {self._n = nil} + + var e: Int32 { + get {return _e ?? 65537} + set {_e = newValue} + } + /// Returns true if `e` has been explicitly set. + var hasE: Bool {return self._e != nil} + /// Clears the value of `e`. Subsequent reads from it will return its default value. + mutating func clearE() {self._e = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _n: Data? = nil + fileprivate var _e: Int32? = nil +} + +/// A convenience proto for encoding Diffie-Hellman public keys, +/// for use only when Elliptic Curve based key exchanges are not possible. +/// (Note that the group parameters must be specified separately) +struct Securemessage_DhPublicKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Big-endian two's complement encoded group element + var y: Data { + get {return _y ?? Data()} + set {_y = newValue} + } + /// Returns true if `y` has been explicitly set. + var hasY: Bool {return self._y != nil} + /// Clears the value of `y`. Subsequent reads from it will return its default value. + mutating func clearY() {self._y = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _y: Data? = nil +} + +struct Securemessage_GenericPublicKey { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var type: Securemessage_PublicKeyType { + get {return _type ?? .ecP256} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + + var ecP256PublicKey: Securemessage_EcP256PublicKey { + get {return _ecP256PublicKey ?? Securemessage_EcP256PublicKey()} + set {_ecP256PublicKey = newValue} + } + /// Returns true if `ecP256PublicKey` has been explicitly set. + var hasEcP256PublicKey: Bool {return self._ecP256PublicKey != nil} + /// Clears the value of `ecP256PublicKey`. Subsequent reads from it will return its default value. + mutating func clearEcP256PublicKey() {self._ecP256PublicKey = nil} + + var rsa2048PublicKey: Securemessage_SimpleRsaPublicKey { + get {return _rsa2048PublicKey ?? Securemessage_SimpleRsaPublicKey()} + set {_rsa2048PublicKey = newValue} + } + /// Returns true if `rsa2048PublicKey` has been explicitly set. + var hasRsa2048PublicKey: Bool {return self._rsa2048PublicKey != nil} + /// Clears the value of `rsa2048PublicKey`. Subsequent reads from it will return its default value. + mutating func clearRsa2048PublicKey() {self._rsa2048PublicKey = nil} + + /// Use only as a last resort + var dh2048PublicKey: Securemessage_DhPublicKey { + get {return _dh2048PublicKey ?? Securemessage_DhPublicKey()} + set {_dh2048PublicKey = newValue} + } + /// Returns true if `dh2048PublicKey` has been explicitly set. + var hasDh2048PublicKey: Bool {return self._dh2048PublicKey != nil} + /// Clears the value of `dh2048PublicKey`. Subsequent reads from it will return its default value. + mutating func clearDh2048PublicKey() {self._dh2048PublicKey = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _type: Securemessage_PublicKeyType? = nil + fileprivate var _ecP256PublicKey: Securemessage_EcP256PublicKey? = nil + fileprivate var _rsa2048PublicKey: Securemessage_SimpleRsaPublicKey? = nil + fileprivate var _dh2048PublicKey: Securemessage_DhPublicKey? = nil +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Securemessage_SigScheme: @unchecked Sendable {} +extension Securemessage_EncScheme: @unchecked Sendable {} +extension Securemessage_PublicKeyType: @unchecked Sendable {} +extension Securemessage_SecureMessage: @unchecked Sendable {} +extension Securemessage_Header: @unchecked Sendable {} +extension Securemessage_HeaderAndBody: @unchecked Sendable {} +extension Securemessage_HeaderAndBodyInternal: @unchecked Sendable {} +extension Securemessage_EcP256PublicKey: @unchecked Sendable {} +extension Securemessage_SimpleRsaPublicKey: @unchecked Sendable {} +extension Securemessage_DhPublicKey: @unchecked Sendable {} +extension Securemessage_GenericPublicKey: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "securemessage" + +extension Securemessage_SigScheme: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "HMAC_SHA256"), + 2: .same(proto: "ECDSA_P256_SHA256"), + 3: .same(proto: "RSA2048_SHA256"), + ] +} + +extension Securemessage_EncScheme: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "NONE"), + 2: .same(proto: "AES_256_CBC"), + ] +} + +extension Securemessage_PublicKeyType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "EC_P256"), + 2: .same(proto: "RSA2048"), + 3: .same(proto: "DH2048_MODP"), + ] +} + +extension Securemessage_SecureMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".SecureMessage" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "header_and_body"), + 2: .same(proto: "signature"), + ] + + public var isInitialized: Bool { + if self._headerAndBody == nil {return false} + if self._signature == nil {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._headerAndBody) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._signature) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._headerAndBody { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._signature { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securemessage_SecureMessage, rhs: Securemessage_SecureMessage) -> Bool { + if lhs._headerAndBody != rhs._headerAndBody {return false} + if lhs._signature != rhs._signature {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securemessage_Header: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Header" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "signature_scheme"), + 2: .standard(proto: "encryption_scheme"), + 3: .standard(proto: "verification_key_id"), + 4: .standard(proto: "decryption_key_id"), + 5: .same(proto: "iv"), + 6: .standard(proto: "public_metadata"), + 7: .standard(proto: "associated_data_length"), + ] + + public var isInitialized: Bool { + if self._signatureScheme == nil {return false} + if self._encryptionScheme == nil {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._signatureScheme) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self._encryptionScheme) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._verificationKeyID) }() + case 4: try { try decoder.decodeSingularBytesField(value: &self._decryptionKeyID) }() + case 5: try { try decoder.decodeSingularBytesField(value: &self._iv) }() + case 6: try { try decoder.decodeSingularBytesField(value: &self._publicMetadata) }() + case 7: try { try decoder.decodeSingularUInt32Field(value: &self._associatedDataLength) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._signatureScheme { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._encryptionScheme { + try visitor.visitSingularEnumField(value: v, fieldNumber: 2) + } }() + try { if let v = self._verificationKeyID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try { if let v = self._decryptionKeyID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 4) + } }() + try { if let v = self._iv { + try visitor.visitSingularBytesField(value: v, fieldNumber: 5) + } }() + try { if let v = self._publicMetadata { + try visitor.visitSingularBytesField(value: v, fieldNumber: 6) + } }() + try { if let v = self._associatedDataLength { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 7) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securemessage_Header, rhs: Securemessage_Header) -> Bool { + if lhs._signatureScheme != rhs._signatureScheme {return false} + if lhs._encryptionScheme != rhs._encryptionScheme {return false} + if lhs._verificationKeyID != rhs._verificationKeyID {return false} + if lhs._decryptionKeyID != rhs._decryptionKeyID {return false} + if lhs._iv != rhs._iv {return false} + if lhs._publicMetadata != rhs._publicMetadata {return false} + if lhs._associatedDataLength != rhs._associatedDataLength {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securemessage_HeaderAndBody: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".HeaderAndBody" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "header"), + 2: .same(proto: "body"), + ] + + public var isInitialized: Bool { + if self._header == nil {return false} + if self._body == nil {return false} + if let v = self._header, !v.isInitialized {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._header) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._body) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._header { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try { if let v = self._body { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securemessage_HeaderAndBody, rhs: Securemessage_HeaderAndBody) -> Bool { + if lhs._header != rhs._header {return false} + if lhs._body != rhs._body {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securemessage_HeaderAndBodyInternal: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".HeaderAndBodyInternal" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "header"), + 2: .same(proto: "body"), + ] + + public var isInitialized: Bool { + if self._header == nil {return false} + if self._body == nil {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._header) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._body) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._header { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._body { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securemessage_HeaderAndBodyInternal, rhs: Securemessage_HeaderAndBodyInternal) -> Bool { + if lhs._header != rhs._header {return false} + if lhs._body != rhs._body {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securemessage_EcP256PublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".EcP256PublicKey" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "x"), + 2: .same(proto: "y"), + ] + + public var isInitialized: Bool { + if self._x == nil {return false} + if self._y == nil {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._x) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._y) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._x { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._y { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securemessage_EcP256PublicKey, rhs: Securemessage_EcP256PublicKey) -> Bool { + if lhs._x != rhs._x {return false} + if lhs._y != rhs._y {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securemessage_SimpleRsaPublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".SimpleRsaPublicKey" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "n"), + 2: .same(proto: "e"), + ] + + public var isInitialized: Bool { + if self._n == nil {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._n) }() + case 2: try { try decoder.decodeSingularInt32Field(value: &self._e) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._n { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._e { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securemessage_SimpleRsaPublicKey, rhs: Securemessage_SimpleRsaPublicKey) -> Bool { + if lhs._n != rhs._n {return false} + if lhs._e != rhs._e {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securemessage_DhPublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".DhPublicKey" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "y"), + ] + + public var isInitialized: Bool { + if self._y == nil {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._y) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._y { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securemessage_DhPublicKey, rhs: Securemessage_DhPublicKey) -> Bool { + if lhs._y != rhs._y {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securemessage_GenericPublicKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".GenericPublicKey" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "ec_p256_public_key"), + 3: .standard(proto: "rsa2048_public_key"), + 4: .standard(proto: "dh2048_public_key"), + ] + + public var isInitialized: Bool { + if self._type == nil {return false} + if let v = self._ecP256PublicKey, !v.isInitialized {return false} + if let v = self._rsa2048PublicKey, !v.isInitialized {return false} + if let v = self._dh2048PublicKey, !v.isInitialized {return false} + return true + } + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._type) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._ecP256PublicKey) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._rsa2048PublicKey) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._dh2048PublicKey) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._ecP256PublicKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try { if let v = self._rsa2048PublicKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try { if let v = self._dh2048PublicKey { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securemessage_GenericPublicKey, rhs: Securemessage_GenericPublicKey) -> Bool { + if lhs._type != rhs._type {return false} + if lhs._ecP256PublicKey != rhs._ecP256PublicKey {return false} + if lhs._rsa2048PublicKey != rhs._rsa2048PublicKey {return false} + if lhs._dh2048PublicKey != rhs._dh2048PublicKey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/NearDrop/Protobuf/ukey.pb.swift b/NearDrop/Protobuf/ukey.pb.swift new file mode 100644 index 0000000..3cbbf2b --- /dev/null +++ b/NearDrop/Protobuf/ukey.pb.swift @@ -0,0 +1,735 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: ukey.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +enum Securegcm_Ukey2HandshakeCipher: SwiftProtobuf.Enum { + typealias RawValue = Int + case reserved // = 0 + + /// NIST P-256 used for ECDH, SHA512 used for + case p256Sha512 // = 100 + + /// commitment + case curve25519Sha512 // = 200 + + init() { + self = .reserved + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .reserved + case 100: self = .p256Sha512 + case 200: self = .curve25519Sha512 + default: return nil + } + } + + var rawValue: Int { + switch self { + case .reserved: return 0 + case .p256Sha512: return 100 + case .curve25519Sha512: return 200 + } + } + +} + +#if swift(>=4.2) + +extension Securegcm_Ukey2HandshakeCipher: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Securegcm_Ukey2Message { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Identifies message type + var messageType: Securegcm_Ukey2Message.TypeEnum { + get {return _messageType ?? .unknownDoNotUse} + set {_messageType = newValue} + } + /// Returns true if `messageType` has been explicitly set. + var hasMessageType: Bool {return self._messageType != nil} + /// Clears the value of `messageType`. Subsequent reads from it will return its default value. + mutating func clearMessageType() {self._messageType = nil} + + /// Actual message, to be parsed according to + var messageData: Data { + get {return _messageData ?? Data()} + set {_messageData = newValue} + } + /// Returns true if `messageData` has been explicitly set. + var hasMessageData: Bool {return self._messageData != nil} + /// Clears the value of `messageData`. Subsequent reads from it will return its default value. + mutating func clearMessageData() {self._messageData = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum TypeEnum: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownDoNotUse // = 0 + case alert // = 1 + case clientInit // = 2 + case serverInit // = 3 + case clientFinish // = 4 + + init() { + self = .unknownDoNotUse + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownDoNotUse + case 1: self = .alert + case 2: self = .clientInit + case 3: self = .serverInit + case 4: self = .clientFinish + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownDoNotUse: return 0 + case .alert: return 1 + case .clientInit: return 2 + case .serverInit: return 3 + case .clientFinish: return 4 + } + } + + } + + init() {} + + fileprivate var _messageType: Securegcm_Ukey2Message.TypeEnum? = nil + fileprivate var _messageData: Data? = nil +} + +#if swift(>=4.2) + +extension Securegcm_Ukey2Message.TypeEnum: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Securegcm_Ukey2Alert { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var type: Securegcm_Ukey2Alert.AlertType { + get {return _type ?? .badMessage} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + + var errorMessage: String { + get {return _errorMessage ?? String()} + set {_errorMessage = newValue} + } + /// Returns true if `errorMessage` has been explicitly set. + var hasErrorMessage: Bool {return self._errorMessage != nil} + /// Clears the value of `errorMessage`. Subsequent reads from it will return its default value. + mutating func clearErrorMessage() {self._errorMessage = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum AlertType: SwiftProtobuf.Enum { + typealias RawValue = Int + + /// Framing errors + case badMessage // = 1 + + /// message_type has an undefined value + case badMessageType // = 2 + + /// message_type received does not correspond to + case incorrectMessage // = 3 + + /// expected type at this stage of the protocol + case badMessageData // = 4 + + /// ClientInit and ServerInit errors + case badVersion // = 100 + + /// suitable version to speak with client. + case badRandom // = 101 + + /// length + case badHandshakeCipher // = 102 + + /// The next protocol is missing, unknown, or + case badNextProtocol // = 103 + + /// unsupported + case badPublicKey // = 104 + + /// Other errors + case internalError // = 200 + + init() { + self = .badMessage + } + + init?(rawValue: Int) { + switch rawValue { + case 1: self = .badMessage + case 2: self = .badMessageType + case 3: self = .incorrectMessage + case 4: self = .badMessageData + case 100: self = .badVersion + case 101: self = .badRandom + case 102: self = .badHandshakeCipher + case 103: self = .badNextProtocol + case 104: self = .badPublicKey + case 200: self = .internalError + default: return nil + } + } + + var rawValue: Int { + switch self { + case .badMessage: return 1 + case .badMessageType: return 2 + case .incorrectMessage: return 3 + case .badMessageData: return 4 + case .badVersion: return 100 + case .badRandom: return 101 + case .badHandshakeCipher: return 102 + case .badNextProtocol: return 103 + case .badPublicKey: return 104 + case .internalError: return 200 + } + } + + } + + init() {} + + fileprivate var _type: Securegcm_Ukey2Alert.AlertType? = nil + fileprivate var _errorMessage: String? = nil +} + +#if swift(>=4.2) + +extension Securegcm_Ukey2Alert.AlertType: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +struct Securegcm_Ukey2ClientInit { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// highest supported version for rollback + var version: Int32 { + get {return _version ?? 0} + set {_version = newValue} + } + /// Returns true if `version` has been explicitly set. + var hasVersion: Bool {return self._version != nil} + /// Clears the value of `version`. Subsequent reads from it will return its default value. + mutating func clearVersion() {self._version = nil} + + /// protection + var random: Data { + get {return _random ?? Data()} + set {_random = newValue} + } + /// Returns true if `random` has been explicitly set. + var hasRandom: Bool {return self._random != nil} + /// Clears the value of `random`. Subsequent reads from it will return its default value. + mutating func clearRandom() {self._random = nil} + + var cipherCommitments: [Securegcm_Ukey2ClientInit.CipherCommitment] = [] + + /// Next protocol that the client wants to speak. + var nextProtocol: String { + get {return _nextProtocol ?? String()} + set {_nextProtocol = newValue} + } + /// Returns true if `nextProtocol` has been explicitly set. + var hasNextProtocol: Bool {return self._nextProtocol != nil} + /// Clears the value of `nextProtocol`. Subsequent reads from it will return its default value. + mutating func clearNextProtocol() {self._nextProtocol = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + /// One commitment (hash of ClientFinished containing public key) per supported + /// cipher + struct CipherCommitment { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var handshakeCipher: Securegcm_Ukey2HandshakeCipher { + get {return _handshakeCipher ?? .reserved} + set {_handshakeCipher = newValue} + } + /// Returns true if `handshakeCipher` has been explicitly set. + var hasHandshakeCipher: Bool {return self._handshakeCipher != nil} + /// Clears the value of `handshakeCipher`. Subsequent reads from it will return its default value. + mutating func clearHandshakeCipher() {self._handshakeCipher = nil} + + var commitment: Data { + get {return _commitment ?? Data()} + set {_commitment = newValue} + } + /// Returns true if `commitment` has been explicitly set. + var hasCommitment: Bool {return self._commitment != nil} + /// Clears the value of `commitment`. Subsequent reads from it will return its default value. + mutating func clearCommitment() {self._commitment = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _handshakeCipher: Securegcm_Ukey2HandshakeCipher? = nil + fileprivate var _commitment: Data? = nil + } + + init() {} + + fileprivate var _version: Int32? = nil + fileprivate var _random: Data? = nil + fileprivate var _nextProtocol: String? = nil +} + +struct Securegcm_Ukey2ServerInit { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// highest supported version for rollback + var version: Int32 { + get {return _version ?? 0} + set {_version = newValue} + } + /// Returns true if `version` has been explicitly set. + var hasVersion: Bool {return self._version != nil} + /// Clears the value of `version`. Subsequent reads from it will return its default value. + mutating func clearVersion() {self._version = nil} + + /// protection + var random: Data { + get {return _random ?? Data()} + set {_random = newValue} + } + /// Returns true if `random` has been explicitly set. + var hasRandom: Bool {return self._random != nil} + /// Clears the value of `random`. Subsequent reads from it will return its default value. + mutating func clearRandom() {self._random = nil} + + /// Selected Cipher and corresponding public key + var handshakeCipher: Securegcm_Ukey2HandshakeCipher { + get {return _handshakeCipher ?? .reserved} + set {_handshakeCipher = newValue} + } + /// Returns true if `handshakeCipher` has been explicitly set. + var hasHandshakeCipher: Bool {return self._handshakeCipher != nil} + /// Clears the value of `handshakeCipher`. Subsequent reads from it will return its default value. + mutating func clearHandshakeCipher() {self._handshakeCipher = nil} + + var publicKey: Data { + get {return _publicKey ?? Data()} + set {_publicKey = newValue} + } + /// Returns true if `publicKey` has been explicitly set. + var hasPublicKey: Bool {return self._publicKey != nil} + /// Clears the value of `publicKey`. Subsequent reads from it will return its default value. + mutating func clearPublicKey() {self._publicKey = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _version: Int32? = nil + fileprivate var _random: Data? = nil + fileprivate var _handshakeCipher: Securegcm_Ukey2HandshakeCipher? = nil + fileprivate var _publicKey: Data? = nil +} + +struct Securegcm_Ukey2ClientFinished { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// public key matching selected handshake + var publicKey: Data { + get {return _publicKey ?? Data()} + set {_publicKey = newValue} + } + /// Returns true if `publicKey` has been explicitly set. + var hasPublicKey: Bool {return self._publicKey != nil} + /// Clears the value of `publicKey`. Subsequent reads from it will return its default value. + mutating func clearPublicKey() {self._publicKey = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _publicKey: Data? = nil +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Securegcm_Ukey2HandshakeCipher: @unchecked Sendable {} +extension Securegcm_Ukey2Message: @unchecked Sendable {} +extension Securegcm_Ukey2Message.TypeEnum: @unchecked Sendable {} +extension Securegcm_Ukey2Alert: @unchecked Sendable {} +extension Securegcm_Ukey2Alert.AlertType: @unchecked Sendable {} +extension Securegcm_Ukey2ClientInit: @unchecked Sendable {} +extension Securegcm_Ukey2ClientInit.CipherCommitment: @unchecked Sendable {} +extension Securegcm_Ukey2ServerInit: @unchecked Sendable {} +extension Securegcm_Ukey2ClientFinished: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "securegcm" + +extension Securegcm_Ukey2HandshakeCipher: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "RESERVED"), + 100: .same(proto: "P256_SHA512"), + 200: .same(proto: "CURVE25519_SHA512"), + ] +} + +extension Securegcm_Ukey2Message: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Ukey2Message" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "message_type"), + 2: .standard(proto: "message_data"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._messageType) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._messageData) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._messageType { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._messageData { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_Ukey2Message, rhs: Securegcm_Ukey2Message) -> Bool { + if lhs._messageType != rhs._messageType {return false} + if lhs._messageData != rhs._messageData {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_Ukey2Message.TypeEnum: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_DO_NOT_USE"), + 1: .same(proto: "ALERT"), + 2: .same(proto: "CLIENT_INIT"), + 3: .same(proto: "SERVER_INIT"), + 4: .same(proto: "CLIENT_FINISH"), + ] +} + +extension Securegcm_Ukey2Alert: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Ukey2Alert" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .standard(proto: "error_message"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._type) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._errorMessage) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._errorMessage { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_Ukey2Alert, rhs: Securegcm_Ukey2Alert) -> Bool { + if lhs._type != rhs._type {return false} + if lhs._errorMessage != rhs._errorMessage {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_Ukey2Alert.AlertType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "BAD_MESSAGE"), + 2: .same(proto: "BAD_MESSAGE_TYPE"), + 3: .same(proto: "INCORRECT_MESSAGE"), + 4: .same(proto: "BAD_MESSAGE_DATA"), + 100: .same(proto: "BAD_VERSION"), + 101: .same(proto: "BAD_RANDOM"), + 102: .same(proto: "BAD_HANDSHAKE_CIPHER"), + 103: .same(proto: "BAD_NEXT_PROTOCOL"), + 104: .same(proto: "BAD_PUBLIC_KEY"), + 200: .same(proto: "INTERNAL_ERROR"), + ] +} + +extension Securegcm_Ukey2ClientInit: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Ukey2ClientInit" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "version"), + 2: .same(proto: "random"), + 3: .standard(proto: "cipher_commitments"), + 4: .standard(proto: "next_protocol"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self._version) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._random) }() + case 3: try { try decoder.decodeRepeatedMessageField(value: &self.cipherCommitments) }() + case 4: try { try decoder.decodeSingularStringField(value: &self._nextProtocol) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._version { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 1) + } }() + try { if let v = self._random { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + if !self.cipherCommitments.isEmpty { + try visitor.visitRepeatedMessageField(value: self.cipherCommitments, fieldNumber: 3) + } + try { if let v = self._nextProtocol { + try visitor.visitSingularStringField(value: v, fieldNumber: 4) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_Ukey2ClientInit, rhs: Securegcm_Ukey2ClientInit) -> Bool { + if lhs._version != rhs._version {return false} + if lhs._random != rhs._random {return false} + if lhs.cipherCommitments != rhs.cipherCommitments {return false} + if lhs._nextProtocol != rhs._nextProtocol {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_Ukey2ClientInit.CipherCommitment: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = Securegcm_Ukey2ClientInit.protoMessageName + ".CipherCommitment" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "handshake_cipher"), + 2: .same(proto: "commitment"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._handshakeCipher) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._commitment) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._handshakeCipher { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._commitment { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_Ukey2ClientInit.CipherCommitment, rhs: Securegcm_Ukey2ClientInit.CipherCommitment) -> Bool { + if lhs._handshakeCipher != rhs._handshakeCipher {return false} + if lhs._commitment != rhs._commitment {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_Ukey2ServerInit: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Ukey2ServerInit" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "version"), + 2: .same(proto: "random"), + 3: .standard(proto: "handshake_cipher"), + 4: .standard(proto: "public_key"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularInt32Field(value: &self._version) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._random) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self._handshakeCipher) }() + case 4: try { try decoder.decodeSingularBytesField(value: &self._publicKey) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._version { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 1) + } }() + try { if let v = self._random { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try { if let v = self._handshakeCipher { + try visitor.visitSingularEnumField(value: v, fieldNumber: 3) + } }() + try { if let v = self._publicKey { + try visitor.visitSingularBytesField(value: v, fieldNumber: 4) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_Ukey2ServerInit, rhs: Securegcm_Ukey2ServerInit) -> Bool { + if lhs._version != rhs._version {return false} + if lhs._random != rhs._random {return false} + if lhs._handshakeCipher != rhs._handshakeCipher {return false} + if lhs._publicKey != rhs._publicKey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Securegcm_Ukey2ClientFinished: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Ukey2ClientFinished" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "public_key"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._publicKey) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._publicKey { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Securegcm_Ukey2ClientFinished, rhs: Securegcm_Ukey2ClientFinished) -> Bool { + if lhs._publicKey != rhs._publicKey {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/NearDrop/Protobuf/wire_format.pb.swift b/NearDrop/Protobuf/wire_format.pb.swift new file mode 100644 index 0000000..d8c5bd0 --- /dev/null +++ b/NearDrop/Protobuf/wire_format.pb.swift @@ -0,0 +1,1617 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: wire_format.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +// Copyright 2020 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Brought from: //depot/google3/location/nearby/sharing/proto/wire_format.proto +// At CL 317565061 + +import Foundation +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +/// File metadata. Does not include the actual bytes of the file. +/// NEXT_ID=6 +struct Sharing_Nearby_FileMetadata { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The human readable name of this file (eg. 'Cookbook.pdf'). + var name: String { + get {return _name ?? String()} + set {_name = newValue} + } + /// Returns true if `name` has been explicitly set. + var hasName: Bool {return self._name != nil} + /// Clears the value of `name`. Subsequent reads from it will return its default value. + mutating func clearName() {self._name = nil} + + /// The type of file (eg. 'IMAGE' from 'dog.jpg'). Specifying a type helps + /// provide a richer experience on the receiving side. + var type: Sharing_Nearby_FileMetadata.TypeEnum { + get {return _type ?? .unknown} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + + /// The FILE payload id that will be sent as a follow up containing the actual + /// bytes of the file. + var payloadID: Int64 { + get {return _payloadID ?? 0} + set {_payloadID = newValue} + } + /// Returns true if `payloadID` has been explicitly set. + var hasPayloadID: Bool {return self._payloadID != nil} + /// Clears the value of `payloadID`. Subsequent reads from it will return its default value. + mutating func clearPayloadID() {self._payloadID = nil} + + /// The total size of the file. + var size: Int64 { + get {return _size ?? 0} + set {_size = newValue} + } + /// Returns true if `size` has been explicitly set. + var hasSize: Bool {return self._size != nil} + /// Clears the value of `size`. Subsequent reads from it will return its default value. + mutating func clearSize() {self._size = nil} + + /// The mimeType of file (eg. 'image/jpeg' from 'dog.jpg'). Specifying a + /// mimeType helps provide a richer experience on receiving side. + var mimeType: String { + get {return _mimeType ?? "application/octet-stream"} + set {_mimeType = newValue} + } + /// Returns true if `mimeType` has been explicitly set. + var hasMimeType: Bool {return self._mimeType != nil} + /// Clears the value of `mimeType`. Subsequent reads from it will return its default value. + mutating func clearMimeType() {self._mimeType = nil} + + /// A uuid for the attachment. Should be unique across all attachments. + var id: Int64 { + get {return _id ?? 0} + set {_id = newValue} + } + /// Returns true if `id` has been explicitly set. + var hasID: Bool {return self._id != nil} + /// Clears the value of `id`. Subsequent reads from it will return its default value. + mutating func clearID() {self._id = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum TypeEnum: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknown // = 0 + case image // = 1 + case video // = 2 + case app // = 3 + case audio // = 4 + + init() { + self = .unknown + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknown + case 1: self = .image + case 2: self = .video + case 3: self = .app + case 4: self = .audio + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknown: return 0 + case .image: return 1 + case .video: return 2 + case .app: return 3 + case .audio: return 4 + } + } + + } + + init() {} + + fileprivate var _name: String? = nil + fileprivate var _type: Sharing_Nearby_FileMetadata.TypeEnum? = nil + fileprivate var _payloadID: Int64? = nil + fileprivate var _size: Int64? = nil + fileprivate var _mimeType: String? = nil + fileprivate var _id: Int64? = nil +} + +#if swift(>=4.2) + +extension Sharing_Nearby_FileMetadata.TypeEnum: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// NEXT_ID=5 +struct Sharing_Nearby_TextMetadata { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The title of the text content. + var textTitle: String { + get {return _textTitle ?? String()} + set {_textTitle = newValue} + } + /// Returns true if `textTitle` has been explicitly set. + var hasTextTitle: Bool {return self._textTitle != nil} + /// Clears the value of `textTitle`. Subsequent reads from it will return its default value. + mutating func clearTextTitle() {self._textTitle = nil} + + /// The type of text (phone number, url, address, or plain text). + var type: Sharing_Nearby_TextMetadata.TypeEnum { + get {return _type ?? .unknown} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + + /// The BYTE payload id that will be sent as a follow up containing the actual + /// bytes of the text. + var payloadID: Int64 { + get {return _payloadID ?? 0} + set {_payloadID = newValue} + } + /// Returns true if `payloadID` has been explicitly set. + var hasPayloadID: Bool {return self._payloadID != nil} + /// Clears the value of `payloadID`. Subsequent reads from it will return its default value. + mutating func clearPayloadID() {self._payloadID = nil} + + /// The size of the text content. + var size: Int64 { + get {return _size ?? 0} + set {_size = newValue} + } + /// Returns true if `size` has been explicitly set. + var hasSize: Bool {return self._size != nil} + /// Clears the value of `size`. Subsequent reads from it will return its default value. + mutating func clearSize() {self._size = nil} + + /// A uuid for the attachment. Should be unique across all attachments. + var id: Int64 { + get {return _id ?? 0} + set {_id = newValue} + } + /// Returns true if `id` has been explicitly set. + var hasID: Bool {return self._id != nil} + /// Clears the value of `id`. Subsequent reads from it will return its default value. + mutating func clearID() {self._id = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum TypeEnum: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknown // = 0 + case text // = 1 + + /// Open with browsers. + case url // = 2 + + /// Open with map apps. + case address // = 3 + + /// Dial. + case phoneNumber // = 4 + + init() { + self = .unknown + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknown + case 1: self = .text + case 2: self = .url + case 3: self = .address + case 4: self = .phoneNumber + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknown: return 0 + case .text: return 1 + case .url: return 2 + case .address: return 3 + case .phoneNumber: return 4 + } + } + + } + + init() {} + + fileprivate var _textTitle: String? = nil + fileprivate var _type: Sharing_Nearby_TextMetadata.TypeEnum? = nil + fileprivate var _payloadID: Int64? = nil + fileprivate var _size: Int64? = nil + fileprivate var _id: Int64? = nil +} + +#if swift(>=4.2) + +extension Sharing_Nearby_TextMetadata.TypeEnum: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// NEXT_ID=5 +struct Sharing_Nearby_WifiCredentialsMetadata { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The Wifi network name. This will be sent in introduction. + var ssid: String { + get {return _ssid ?? String()} + set {_ssid = newValue} + } + /// Returns true if `ssid` has been explicitly set. + var hasSsid: Bool {return self._ssid != nil} + /// Clears the value of `ssid`. Subsequent reads from it will return its default value. + mutating func clearSsid() {self._ssid = nil} + + /// The security type of network (OPEN, WPA_PSK, WEP). + var securityType: Sharing_Nearby_WifiCredentialsMetadata.SecurityType { + get {return _securityType ?? .unknownSecurityType} + set {_securityType = newValue} + } + /// Returns true if `securityType` has been explicitly set. + var hasSecurityType: Bool {return self._securityType != nil} + /// Clears the value of `securityType`. Subsequent reads from it will return its default value. + mutating func clearSecurityType() {self._securityType = nil} + + /// The BYTE payload id that will be sent as a follow up containing the + /// password. + var payloadID: Int64 { + get {return _payloadID ?? 0} + set {_payloadID = newValue} + } + /// Returns true if `payloadID` has been explicitly set. + var hasPayloadID: Bool {return self._payloadID != nil} + /// Clears the value of `payloadID`. Subsequent reads from it will return its default value. + mutating func clearPayloadID() {self._payloadID = nil} + + /// A uuid for the attachment. Should be unique across all attachments. + var id: Int64 { + get {return _id ?? 0} + set {_id = newValue} + } + /// Returns true if `id` has been explicitly set. + var hasID: Bool {return self._id != nil} + /// Clears the value of `id`. Subsequent reads from it will return its default value. + mutating func clearID() {self._id = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum SecurityType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownSecurityType // = 0 + case `open` // = 1 + case wpaPsk // = 2 + case wep // = 3 + + init() { + self = .unknownSecurityType + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownSecurityType + case 1: self = .open + case 2: self = .wpaPsk + case 3: self = .wep + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownSecurityType: return 0 + case .open: return 1 + case .wpaPsk: return 2 + case .wep: return 3 + } + } + + } + + init() {} + + fileprivate var _ssid: String? = nil + fileprivate var _securityType: Sharing_Nearby_WifiCredentialsMetadata.SecurityType? = nil + fileprivate var _payloadID: Int64? = nil + fileprivate var _id: Int64? = nil +} + +#if swift(>=4.2) + +extension Sharing_Nearby_WifiCredentialsMetadata.SecurityType: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// A frame used when sending messages over the wire. +/// NEXT_ID=3 +struct Sharing_Nearby_Frame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var version: Sharing_Nearby_Frame.Version { + get {return _version ?? .unknownVersion} + set {_version = newValue} + } + /// Returns true if `version` has been explicitly set. + var hasVersion: Bool {return self._version != nil} + /// Clears the value of `version`. Subsequent reads from it will return its default value. + mutating func clearVersion() {self._version = nil} + + /// Right now there's only 1 version, but if there are more, exactly one of + /// the following fields will be set. + var v1: Sharing_Nearby_V1Frame { + get {return _v1 ?? Sharing_Nearby_V1Frame()} + set {_v1 = newValue} + } + /// Returns true if `v1` has been explicitly set. + var hasV1: Bool {return self._v1 != nil} + /// Clears the value of `v1`. Subsequent reads from it will return its default value. + mutating func clearV1() {self._v1 = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum Version: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownVersion // = 0 + case v1 // = 1 + + init() { + self = .unknownVersion + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownVersion + case 1: self = .v1 + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownVersion: return 0 + case .v1: return 1 + } + } + + } + + init() {} + + fileprivate var _version: Sharing_Nearby_Frame.Version? = nil + fileprivate var _v1: Sharing_Nearby_V1Frame? = nil +} + +#if swift(>=4.2) + +extension Sharing_Nearby_Frame.Version: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// NEXT_ID=7 +struct Sharing_Nearby_V1Frame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var type: Sharing_Nearby_V1Frame.FrameType { + get {return _type ?? .unknownFrameType} + set {_type = newValue} + } + /// Returns true if `type` has been explicitly set. + var hasType: Bool {return self._type != nil} + /// Clears the value of `type`. Subsequent reads from it will return its default value. + mutating func clearType() {self._type = nil} + + /// Exactly one of the following fields will be set. + var introduction: Sharing_Nearby_IntroductionFrame { + get {return _introduction ?? Sharing_Nearby_IntroductionFrame()} + set {_introduction = newValue} + } + /// Returns true if `introduction` has been explicitly set. + var hasIntroduction: Bool {return self._introduction != nil} + /// Clears the value of `introduction`. Subsequent reads from it will return its default value. + mutating func clearIntroduction() {self._introduction = nil} + + var connectionResponse: Sharing_Nearby_ConnectionResponseFrame { + get {return _connectionResponse ?? Sharing_Nearby_ConnectionResponseFrame()} + set {_connectionResponse = newValue} + } + /// Returns true if `connectionResponse` has been explicitly set. + var hasConnectionResponse: Bool {return self._connectionResponse != nil} + /// Clears the value of `connectionResponse`. Subsequent reads from it will return its default value. + mutating func clearConnectionResponse() {self._connectionResponse = nil} + + var pairedKeyEncryption: Sharing_Nearby_PairedKeyEncryptionFrame { + get {return _pairedKeyEncryption ?? Sharing_Nearby_PairedKeyEncryptionFrame()} + set {_pairedKeyEncryption = newValue} + } + /// Returns true if `pairedKeyEncryption` has been explicitly set. + var hasPairedKeyEncryption: Bool {return self._pairedKeyEncryption != nil} + /// Clears the value of `pairedKeyEncryption`. Subsequent reads from it will return its default value. + mutating func clearPairedKeyEncryption() {self._pairedKeyEncryption = nil} + + var pairedKeyResult: Sharing_Nearby_PairedKeyResultFrame { + get {return _pairedKeyResult ?? Sharing_Nearby_PairedKeyResultFrame()} + set {_pairedKeyResult = newValue} + } + /// Returns true if `pairedKeyResult` has been explicitly set. + var hasPairedKeyResult: Bool {return self._pairedKeyResult != nil} + /// Clears the value of `pairedKeyResult`. Subsequent reads from it will return its default value. + mutating func clearPairedKeyResult() {self._pairedKeyResult = nil} + + var certificateInfo: Sharing_Nearby_CertificateInfoFrame { + get {return _certificateInfo ?? Sharing_Nearby_CertificateInfoFrame()} + set {_certificateInfo = newValue} + } + /// Returns true if `certificateInfo` has been explicitly set. + var hasCertificateInfo: Bool {return self._certificateInfo != nil} + /// Clears the value of `certificateInfo`. Subsequent reads from it will return its default value. + mutating func clearCertificateInfo() {self._certificateInfo = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum FrameType: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknownFrameType // = 0 + case introduction // = 1 + case response // = 2 + case pairedKeyEncryption // = 3 + case pairedKeyResult // = 4 + case certificateInfo // = 5 + case cancel // = 6 + + init() { + self = .unknownFrameType + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknownFrameType + case 1: self = .introduction + case 2: self = .response + case 3: self = .pairedKeyEncryption + case 4: self = .pairedKeyResult + case 5: self = .certificateInfo + case 6: self = .cancel + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknownFrameType: return 0 + case .introduction: return 1 + case .response: return 2 + case .pairedKeyEncryption: return 3 + case .pairedKeyResult: return 4 + case .certificateInfo: return 5 + case .cancel: return 6 + } + } + + } + + init() {} + + fileprivate var _type: Sharing_Nearby_V1Frame.FrameType? = nil + fileprivate var _introduction: Sharing_Nearby_IntroductionFrame? = nil + fileprivate var _connectionResponse: Sharing_Nearby_ConnectionResponseFrame? = nil + fileprivate var _pairedKeyEncryption: Sharing_Nearby_PairedKeyEncryptionFrame? = nil + fileprivate var _pairedKeyResult: Sharing_Nearby_PairedKeyResultFrame? = nil + fileprivate var _certificateInfo: Sharing_Nearby_CertificateInfoFrame? = nil +} + +#if swift(>=4.2) + +extension Sharing_Nearby_V1Frame.FrameType: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// An introduction packet sent by the sending side. Contains a list of files +/// they'd like to share. +/// NEXT_ID=4 +struct Sharing_Nearby_IntroductionFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var fileMetadata: [Sharing_Nearby_FileMetadata] = [] + + var textMetadata: [Sharing_Nearby_TextMetadata] = [] + + /// The required app package to open the content. May be null. + var requiredPackage: String { + get {return _requiredPackage ?? String()} + set {_requiredPackage = newValue} + } + /// Returns true if `requiredPackage` has been explicitly set. + var hasRequiredPackage: Bool {return self._requiredPackage != nil} + /// Clears the value of `requiredPackage`. Subsequent reads from it will return its default value. + mutating func clearRequiredPackage() {self._requiredPackage = nil} + + var wifiCredentialsMetadata: [Sharing_Nearby_WifiCredentialsMetadata] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _requiredPackage: String? = nil +} + +/// A response packet sent by the receiving side. Accepts or rejects the list of +/// files. +/// NEXT_ID=2 +struct Sharing_Nearby_ConnectionResponseFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The receiving side's response. + var status: Sharing_Nearby_ConnectionResponseFrame.Status { + get {return _status ?? .unknown} + set {_status = newValue} + } + /// Returns true if `status` has been explicitly set. + var hasStatus: Bool {return self._status != nil} + /// Clears the value of `status`. Subsequent reads from it will return its default value. + mutating func clearStatus() {self._status = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum Status: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknown // = 0 + case accept // = 1 + case reject // = 2 + case notEnoughSpace // = 3 + case unsupportedAttachmentType // = 4 + case timedOut // = 5 + + init() { + self = .unknown + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknown + case 1: self = .accept + case 2: self = .reject + case 3: self = .notEnoughSpace + case 4: self = .unsupportedAttachmentType + case 5: self = .timedOut + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknown: return 0 + case .accept: return 1 + case .reject: return 2 + case .notEnoughSpace: return 3 + case .unsupportedAttachmentType: return 4 + case .timedOut: return 5 + } + } + + } + + init() {} + + fileprivate var _status: Sharing_Nearby_ConnectionResponseFrame.Status? = nil +} + +#if swift(>=4.2) + +extension Sharing_Nearby_ConnectionResponseFrame.Status: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// A paired key encryption packet sent between devices, contains signed data. +/// NEXT_ID=3 +struct Sharing_Nearby_PairedKeyEncryptionFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The encrypted data in byte array format. + var signedData: Data { + get {return _signedData ?? Data()} + set {_signedData = newValue} + } + /// Returns true if `signedData` has been explicitly set. + var hasSignedData: Bool {return self._signedData != nil} + /// Clears the value of `signedData`. Subsequent reads from it will return its default value. + mutating func clearSignedData() {self._signedData = nil} + + /// The hash of a certificate id. + var secretIDHash: Data { + get {return _secretIDHash ?? Data()} + set {_secretIDHash = newValue} + } + /// Returns true if `secretIDHash` has been explicitly set. + var hasSecretIDHash: Bool {return self._secretIDHash != nil} + /// Clears the value of `secretIDHash`. Subsequent reads from it will return its default value. + mutating func clearSecretIDHash() {self._secretIDHash = nil} + + /// An optional encrypted data in byte array format. + var optionalSignedData: Data { + get {return _optionalSignedData ?? Data()} + set {_optionalSignedData = newValue} + } + /// Returns true if `optionalSignedData` has been explicitly set. + var hasOptionalSignedData: Bool {return self._optionalSignedData != nil} + /// Clears the value of `optionalSignedData`. Subsequent reads from it will return its default value. + mutating func clearOptionalSignedData() {self._optionalSignedData = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _signedData: Data? = nil + fileprivate var _secretIDHash: Data? = nil + fileprivate var _optionalSignedData: Data? = nil +} + +/// A paired key verification result packet sent between devices. +/// NEXT_ID=2 +struct Sharing_Nearby_PairedKeyResultFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The verification result. + var status: Sharing_Nearby_PairedKeyResultFrame.Status { + get {return _status ?? .unknown} + set {_status = newValue} + } + /// Returns true if `status` has been explicitly set. + var hasStatus: Bool {return self._status != nil} + /// Clears the value of `status`. Subsequent reads from it will return its default value. + mutating func clearStatus() {self._status = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum Status: SwiftProtobuf.Enum { + typealias RawValue = Int + case unknown // = 0 + case success // = 1 + case fail // = 2 + case unable // = 3 + + init() { + self = .unknown + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .unknown + case 1: self = .success + case 2: self = .fail + case 3: self = .unable + default: return nil + } + } + + var rawValue: Int { + switch self { + case .unknown: return 0 + case .success: return 1 + case .fail: return 2 + case .unable: return 3 + } + } + + } + + init() {} + + fileprivate var _status: Sharing_Nearby_PairedKeyResultFrame.Status? = nil +} + +#if swift(>=4.2) + +extension Sharing_Nearby_PairedKeyResultFrame.Status: CaseIterable { + // Support synthesized by the compiler. +} + +#endif // swift(>=4.2) + +/// A package containing certificate info to be shared to remote device offline. +/// NEXT_ID=2 +struct Sharing_Nearby_CertificateInfoFrame { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The public certificates to be shared with remote devices. + var publicCertificate: [Sharing_Nearby_PublicCertificate] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +/// A public certificate from the local device. +/// NEXT_ID=8 +struct Sharing_Nearby_PublicCertificate { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// The unique id of the public certificate. + var secretID: Data { + get {return _secretID ?? Data()} + set {_secretID = newValue} + } + /// Returns true if `secretID` has been explicitly set. + var hasSecretID: Bool {return self._secretID != nil} + /// Clears the value of `secretID`. Subsequent reads from it will return its default value. + mutating func clearSecretID() {self._secretID = nil} + + /// A bytes representation of a Secret Key owned by contact, to decrypt the + /// metadata_key stored within the advertisement. + var authenticityKey: Data { + get {return _authenticityKey ?? Data()} + set {_authenticityKey = newValue} + } + /// Returns true if `authenticityKey` has been explicitly set. + var hasAuthenticityKey: Bool {return self._authenticityKey != nil} + /// Clears the value of `authenticityKey`. Subsequent reads from it will return its default value. + mutating func clearAuthenticityKey() {self._authenticityKey = nil} + + /// A bytes representation a public key of X509Certificate, owned by contact, + /// to decrypt encrypted UKEY2 (from Nearby Connections API) as a hand shake in + /// contact verification phase. + var publicKey: Data { + get {return _publicKey ?? Data()} + set {_publicKey = newValue} + } + /// Returns true if `publicKey` has been explicitly set. + var hasPublicKey: Bool {return self._publicKey != nil} + /// Clears the value of `publicKey`. Subsequent reads from it will return its default value. + mutating func clearPublicKey() {self._publicKey = nil} + + /// The time in millis from epoch when this certificate becomes effective. + var startTime: Int64 { + get {return _startTime ?? 0} + set {_startTime = newValue} + } + /// Returns true if `startTime` has been explicitly set. + var hasStartTime: Bool {return self._startTime != nil} + /// Clears the value of `startTime`. Subsequent reads from it will return its default value. + mutating func clearStartTime() {self._startTime = nil} + + /// The time in millis from epoch when this certificate expires. + var endTime: Int64 { + get {return _endTime ?? 0} + set {_endTime = newValue} + } + /// Returns true if `endTime` has been explicitly set. + var hasEndTime: Bool {return self._endTime != nil} + /// Clears the value of `endTime`. Subsequent reads from it will return its default value. + mutating func clearEndTime() {self._endTime = nil} + + /// The encrypted metadata in bytes, contains personal information of the + /// device/user who created this certificate. Needs to be decrypted into bytes, + /// and converted back to EncryptedMetadata object to access fields. + var encryptedMetadataBytes: Data { + get {return _encryptedMetadataBytes ?? Data()} + set {_encryptedMetadataBytes = newValue} + } + /// Returns true if `encryptedMetadataBytes` has been explicitly set. + var hasEncryptedMetadataBytes: Bool {return self._encryptedMetadataBytes != nil} + /// Clears the value of `encryptedMetadataBytes`. Subsequent reads from it will return its default value. + mutating func clearEncryptedMetadataBytes() {self._encryptedMetadataBytes = nil} + + /// The tag for verifying metadata_encryption_key. + var metadataEncryptionKeyTag: Data { + get {return _metadataEncryptionKeyTag ?? Data()} + set {_metadataEncryptionKeyTag = newValue} + } + /// Returns true if `metadataEncryptionKeyTag` has been explicitly set. + var hasMetadataEncryptionKeyTag: Bool {return self._metadataEncryptionKeyTag != nil} + /// Clears the value of `metadataEncryptionKeyTag`. Subsequent reads from it will return its default value. + mutating func clearMetadataEncryptionKeyTag() {self._metadataEncryptionKeyTag = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _secretID: Data? = nil + fileprivate var _authenticityKey: Data? = nil + fileprivate var _publicKey: Data? = nil + fileprivate var _startTime: Int64? = nil + fileprivate var _endTime: Int64? = nil + fileprivate var _encryptedMetadataBytes: Data? = nil + fileprivate var _metadataEncryptionKeyTag: Data? = nil +} + +/// NEXT_ID=3 +struct Sharing_Nearby_WifiCredentials { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// Wi-Fi password. + var password: String { + get {return _password ?? String()} + set {_password = newValue} + } + /// Returns true if `password` has been explicitly set. + var hasPassword: Bool {return self._password != nil} + /// Clears the value of `password`. Subsequent reads from it will return its default value. + mutating func clearPassword() {self._password = nil} + + /// True if the network is a hidden network that is not broadcasting its SSID. + /// Default is false. + var hiddenSsid: Bool { + get {return _hiddenSsid ?? false} + set {_hiddenSsid = newValue} + } + /// Returns true if `hiddenSsid` has been explicitly set. + var hasHiddenSsid: Bool {return self._hiddenSsid != nil} + /// Clears the value of `hiddenSsid`. Subsequent reads from it will return its default value. + mutating func clearHiddenSsid() {self._hiddenSsid = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + + fileprivate var _password: String? = nil + fileprivate var _hiddenSsid: Bool? = nil +} + +#if swift(>=5.5) && canImport(_Concurrency) +extension Sharing_Nearby_FileMetadata: @unchecked Sendable {} +extension Sharing_Nearby_FileMetadata.TypeEnum: @unchecked Sendable {} +extension Sharing_Nearby_TextMetadata: @unchecked Sendable {} +extension Sharing_Nearby_TextMetadata.TypeEnum: @unchecked Sendable {} +extension Sharing_Nearby_WifiCredentialsMetadata: @unchecked Sendable {} +extension Sharing_Nearby_WifiCredentialsMetadata.SecurityType: @unchecked Sendable {} +extension Sharing_Nearby_Frame: @unchecked Sendable {} +extension Sharing_Nearby_Frame.Version: @unchecked Sendable {} +extension Sharing_Nearby_V1Frame: @unchecked Sendable {} +extension Sharing_Nearby_V1Frame.FrameType: @unchecked Sendable {} +extension Sharing_Nearby_IntroductionFrame: @unchecked Sendable {} +extension Sharing_Nearby_ConnectionResponseFrame: @unchecked Sendable {} +extension Sharing_Nearby_ConnectionResponseFrame.Status: @unchecked Sendable {} +extension Sharing_Nearby_PairedKeyEncryptionFrame: @unchecked Sendable {} +extension Sharing_Nearby_PairedKeyResultFrame: @unchecked Sendable {} +extension Sharing_Nearby_PairedKeyResultFrame.Status: @unchecked Sendable {} +extension Sharing_Nearby_CertificateInfoFrame: @unchecked Sendable {} +extension Sharing_Nearby_PublicCertificate: @unchecked Sendable {} +extension Sharing_Nearby_WifiCredentials: @unchecked Sendable {} +#endif // swift(>=5.5) && canImport(_Concurrency) + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "sharing.nearby" + +extension Sharing_Nearby_FileMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".FileMetadata" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "name"), + 2: .same(proto: "type"), + 3: .standard(proto: "payload_id"), + 4: .same(proto: "size"), + 5: .standard(proto: "mime_type"), + 6: .same(proto: "id"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._name) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self._type) }() + case 3: try { try decoder.decodeSingularInt64Field(value: &self._payloadID) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self._size) }() + case 5: try { try decoder.decodeSingularStringField(value: &self._mimeType) }() + case 6: try { try decoder.decodeSingularInt64Field(value: &self._id) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._name { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 2) + } }() + try { if let v = self._payloadID { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 3) + } }() + try { if let v = self._size { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 4) + } }() + try { if let v = self._mimeType { + try visitor.visitSingularStringField(value: v, fieldNumber: 5) + } }() + try { if let v = self._id { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 6) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_FileMetadata, rhs: Sharing_Nearby_FileMetadata) -> Bool { + if lhs._name != rhs._name {return false} + if lhs._type != rhs._type {return false} + if lhs._payloadID != rhs._payloadID {return false} + if lhs._size != rhs._size {return false} + if lhs._mimeType != rhs._mimeType {return false} + if lhs._id != rhs._id {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_FileMetadata.TypeEnum: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "IMAGE"), + 2: .same(proto: "VIDEO"), + 3: .same(proto: "APP"), + 4: .same(proto: "AUDIO"), + ] +} + +extension Sharing_Nearby_TextMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".TextMetadata" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 2: .standard(proto: "text_title"), + 3: .same(proto: "type"), + 4: .standard(proto: "payload_id"), + 5: .same(proto: "size"), + 6: .same(proto: "id"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 2: try { try decoder.decodeSingularStringField(value: &self._textTitle) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self._type) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self._payloadID) }() + case 5: try { try decoder.decodeSingularInt64Field(value: &self._size) }() + case 6: try { try decoder.decodeSingularInt64Field(value: &self._id) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._textTitle { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 3) + } }() + try { if let v = self._payloadID { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 4) + } }() + try { if let v = self._size { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 5) + } }() + try { if let v = self._id { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 6) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_TextMetadata, rhs: Sharing_Nearby_TextMetadata) -> Bool { + if lhs._textTitle != rhs._textTitle {return false} + if lhs._type != rhs._type {return false} + if lhs._payloadID != rhs._payloadID {return false} + if lhs._size != rhs._size {return false} + if lhs._id != rhs._id {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_TextMetadata.TypeEnum: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "TEXT"), + 2: .same(proto: "URL"), + 3: .same(proto: "ADDRESS"), + 4: .same(proto: "PHONE_NUMBER"), + ] +} + +extension Sharing_Nearby_WifiCredentialsMetadata: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".WifiCredentialsMetadata" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 2: .same(proto: "ssid"), + 3: .standard(proto: "security_type"), + 4: .standard(proto: "payload_id"), + 5: .same(proto: "id"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 2: try { try decoder.decodeSingularStringField(value: &self._ssid) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self._securityType) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self._payloadID) }() + case 5: try { try decoder.decodeSingularInt64Field(value: &self._id) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._ssid { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } }() + try { if let v = self._securityType { + try visitor.visitSingularEnumField(value: v, fieldNumber: 3) + } }() + try { if let v = self._payloadID { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 4) + } }() + try { if let v = self._id { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 5) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_WifiCredentialsMetadata, rhs: Sharing_Nearby_WifiCredentialsMetadata) -> Bool { + if lhs._ssid != rhs._ssid {return false} + if lhs._securityType != rhs._securityType {return false} + if lhs._payloadID != rhs._payloadID {return false} + if lhs._id != rhs._id {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_WifiCredentialsMetadata.SecurityType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_SECURITY_TYPE"), + 1: .same(proto: "OPEN"), + 2: .same(proto: "WPA_PSK"), + 3: .same(proto: "WEP"), + ] +} + +extension Sharing_Nearby_Frame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".Frame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "version"), + 2: .same(proto: "v1"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._version) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._v1) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._version { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._v1 { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_Frame, rhs: Sharing_Nearby_Frame) -> Bool { + if lhs._version != rhs._version {return false} + if lhs._v1 != rhs._v1 {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_Frame.Version: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_VERSION"), + 1: .same(proto: "V1"), + ] +} + +extension Sharing_Nearby_V1Frame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".V1Frame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "type"), + 2: .same(proto: "introduction"), + 3: .standard(proto: "connection_response"), + 4: .standard(proto: "paired_key_encryption"), + 5: .standard(proto: "paired_key_result"), + 6: .standard(proto: "certificate_info"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._type) }() + case 2: try { try decoder.decodeSingularMessageField(value: &self._introduction) }() + case 3: try { try decoder.decodeSingularMessageField(value: &self._connectionResponse) }() + case 4: try { try decoder.decodeSingularMessageField(value: &self._pairedKeyEncryption) }() + case 5: try { try decoder.decodeSingularMessageField(value: &self._pairedKeyResult) }() + case 6: try { try decoder.decodeSingularMessageField(value: &self._certificateInfo) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._type { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try { if let v = self._introduction { + try visitor.visitSingularMessageField(value: v, fieldNumber: 2) + } }() + try { if let v = self._connectionResponse { + try visitor.visitSingularMessageField(value: v, fieldNumber: 3) + } }() + try { if let v = self._pairedKeyEncryption { + try visitor.visitSingularMessageField(value: v, fieldNumber: 4) + } }() + try { if let v = self._pairedKeyResult { + try visitor.visitSingularMessageField(value: v, fieldNumber: 5) + } }() + try { if let v = self._certificateInfo { + try visitor.visitSingularMessageField(value: v, fieldNumber: 6) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_V1Frame, rhs: Sharing_Nearby_V1Frame) -> Bool { + if lhs._type != rhs._type {return false} + if lhs._introduction != rhs._introduction {return false} + if lhs._connectionResponse != rhs._connectionResponse {return false} + if lhs._pairedKeyEncryption != rhs._pairedKeyEncryption {return false} + if lhs._pairedKeyResult != rhs._pairedKeyResult {return false} + if lhs._certificateInfo != rhs._certificateInfo {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_V1Frame.FrameType: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN_FRAME_TYPE"), + 1: .same(proto: "INTRODUCTION"), + 2: .same(proto: "RESPONSE"), + 3: .same(proto: "PAIRED_KEY_ENCRYPTION"), + 4: .same(proto: "PAIRED_KEY_RESULT"), + 5: .same(proto: "CERTIFICATE_INFO"), + 6: .same(proto: "CANCEL"), + ] +} + +extension Sharing_Nearby_IntroductionFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".IntroductionFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "file_metadata"), + 2: .standard(proto: "text_metadata"), + 3: .standard(proto: "required_package"), + 4: .standard(proto: "wifi_credentials_metadata"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.fileMetadata) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.textMetadata) }() + case 3: try { try decoder.decodeSingularStringField(value: &self._requiredPackage) }() + case 4: try { try decoder.decodeRepeatedMessageField(value: &self.wifiCredentialsMetadata) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + if !self.fileMetadata.isEmpty { + try visitor.visitRepeatedMessageField(value: self.fileMetadata, fieldNumber: 1) + } + if !self.textMetadata.isEmpty { + try visitor.visitRepeatedMessageField(value: self.textMetadata, fieldNumber: 2) + } + try { if let v = self._requiredPackage { + try visitor.visitSingularStringField(value: v, fieldNumber: 3) + } }() + if !self.wifiCredentialsMetadata.isEmpty { + try visitor.visitRepeatedMessageField(value: self.wifiCredentialsMetadata, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_IntroductionFrame, rhs: Sharing_Nearby_IntroductionFrame) -> Bool { + if lhs.fileMetadata != rhs.fileMetadata {return false} + if lhs.textMetadata != rhs.textMetadata {return false} + if lhs._requiredPackage != rhs._requiredPackage {return false} + if lhs.wifiCredentialsMetadata != rhs.wifiCredentialsMetadata {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_ConnectionResponseFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".ConnectionResponseFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._status) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._status { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_ConnectionResponseFrame, rhs: Sharing_Nearby_ConnectionResponseFrame) -> Bool { + if lhs._status != rhs._status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_ConnectionResponseFrame.Status: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "ACCEPT"), + 2: .same(proto: "REJECT"), + 3: .same(proto: "NOT_ENOUGH_SPACE"), + 4: .same(proto: "UNSUPPORTED_ATTACHMENT_TYPE"), + 5: .same(proto: "TIMED_OUT"), + ] +} + +extension Sharing_Nearby_PairedKeyEncryptionFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".PairedKeyEncryptionFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "signed_data"), + 2: .standard(proto: "secret_id_hash"), + 3: .standard(proto: "optional_signed_data"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._signedData) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._secretIDHash) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._optionalSignedData) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._signedData { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._secretIDHash { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try { if let v = self._optionalSignedData { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_PairedKeyEncryptionFrame, rhs: Sharing_Nearby_PairedKeyEncryptionFrame) -> Bool { + if lhs._signedData != rhs._signedData {return false} + if lhs._secretIDHash != rhs._secretIDHash {return false} + if lhs._optionalSignedData != rhs._optionalSignedData {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_PairedKeyResultFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".PairedKeyResultFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "status"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self._status) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._status { + try visitor.visitSingularEnumField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_PairedKeyResultFrame, rhs: Sharing_Nearby_PairedKeyResultFrame) -> Bool { + if lhs._status != rhs._status {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_PairedKeyResultFrame.Status: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "UNKNOWN"), + 1: .same(proto: "SUCCESS"), + 2: .same(proto: "FAIL"), + 3: .same(proto: "UNABLE"), + ] +} + +extension Sharing_Nearby_CertificateInfoFrame: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".CertificateInfoFrame" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "public_certificate"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.publicCertificate) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.publicCertificate.isEmpty { + try visitor.visitRepeatedMessageField(value: self.publicCertificate, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_CertificateInfoFrame, rhs: Sharing_Nearby_CertificateInfoFrame) -> Bool { + if lhs.publicCertificate != rhs.publicCertificate {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_PublicCertificate: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".PublicCertificate" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "secret_id"), + 2: .standard(proto: "authenticity_key"), + 3: .standard(proto: "public_key"), + 4: .standard(proto: "start_time"), + 5: .standard(proto: "end_time"), + 6: .standard(proto: "encrypted_metadata_bytes"), + 7: .standard(proto: "metadata_encryption_key_tag"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularBytesField(value: &self._secretID) }() + case 2: try { try decoder.decodeSingularBytesField(value: &self._authenticityKey) }() + case 3: try { try decoder.decodeSingularBytesField(value: &self._publicKey) }() + case 4: try { try decoder.decodeSingularInt64Field(value: &self._startTime) }() + case 5: try { try decoder.decodeSingularInt64Field(value: &self._endTime) }() + case 6: try { try decoder.decodeSingularBytesField(value: &self._encryptedMetadataBytes) }() + case 7: try { try decoder.decodeSingularBytesField(value: &self._metadataEncryptionKeyTag) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._secretID { + try visitor.visitSingularBytesField(value: v, fieldNumber: 1) + } }() + try { if let v = self._authenticityKey { + try visitor.visitSingularBytesField(value: v, fieldNumber: 2) + } }() + try { if let v = self._publicKey { + try visitor.visitSingularBytesField(value: v, fieldNumber: 3) + } }() + try { if let v = self._startTime { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 4) + } }() + try { if let v = self._endTime { + try visitor.visitSingularInt64Field(value: v, fieldNumber: 5) + } }() + try { if let v = self._encryptedMetadataBytes { + try visitor.visitSingularBytesField(value: v, fieldNumber: 6) + } }() + try { if let v = self._metadataEncryptionKeyTag { + try visitor.visitSingularBytesField(value: v, fieldNumber: 7) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_PublicCertificate, rhs: Sharing_Nearby_PublicCertificate) -> Bool { + if lhs._secretID != rhs._secretID {return false} + if lhs._authenticityKey != rhs._authenticityKey {return false} + if lhs._publicKey != rhs._publicKey {return false} + if lhs._startTime != rhs._startTime {return false} + if lhs._endTime != rhs._endTime {return false} + if lhs._encryptedMetadataBytes != rhs._encryptedMetadataBytes {return false} + if lhs._metadataEncryptionKeyTag != rhs._metadataEncryptionKeyTag {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Sharing_Nearby_WifiCredentials: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".WifiCredentials" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "password"), + 2: .standard(proto: "hidden_ssid"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self._password) }() + case 2: try { try decoder.decodeSingularBoolField(value: &self._hiddenSsid) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._password { + try visitor.visitSingularStringField(value: v, fieldNumber: 1) + } }() + try { if let v = self._hiddenSsid { + try visitor.visitSingularBoolField(value: v, fieldNumber: 2) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: Sharing_Nearby_WifiCredentials, rhs: Sharing_Nearby_WifiCredentials) -> Bool { + if lhs._password != rhs._password {return false} + if lhs._hiddenSsid != rhs._hiddenSsid {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} diff --git a/NearDrop/ProtobufSource/device_to_device_messages.proto b/NearDrop/ProtobufSource/device_to_device_messages.proto new file mode 100644 index 0000000..5600373 --- /dev/null +++ b/NearDrop/ProtobufSource/device_to_device_messages.proto @@ -0,0 +1,81 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +package securegcm; + +import "securemessage.proto"; + +option optimize_for = LITE_RUNTIME; +option java_package = "com.google.security.cryptauth.lib.securegcm"; +option java_outer_classname = "DeviceToDeviceMessagesProto"; +option objc_class_prefix = "SGCM"; + +// Used by protocols between devices +message DeviceToDeviceMessage { + // the payload of the message + optional bytes message = 1; + + // the sequence number of the message - must be increasing. + optional int32 sequence_number = 2; +} + +// sent as the first message from initiator to responder +// in an unauthenticated Diffie-Hellman Key Exchange +message InitiatorHello { + // The session public key to send to the responder + optional securemessage.GenericPublicKey public_dh_key = 1; + + // The protocol version + optional int32 protocol_version = 2 [default = 0]; +} + +// sent inside the header of the first message from the responder to the +// initiator in an unauthenticated Diffie-Hellman Key Exchange +message ResponderHello { + // The session public key to send to the initiator + optional securemessage.GenericPublicKey public_dh_key = 1; + + // The protocol version + optional int32 protocol_version = 2 [default = 0]; +} + +// Type of curve +enum Curve { ED_25519 = 1; } + +// A convenience proto for encoding curve points in affine representation +message EcPoint { + required Curve curve = 1; + + // x and y are encoded in big-endian two's complement + // client MUST verify (x,y) is a valid point on the specified curve + required bytes x = 2; + required bytes y = 3; +} + +message SpakeHandshakeMessage { + // Each flow in the protocol bumps this counter + optional int32 flow_number = 1; + + // Some (but not all) SPAKE flows send a point on an elliptic curve + optional EcPoint ec_point = 2; + + // Some (but not all) SPAKE flows send a hash value + optional bytes hash_value = 3; + + // The last flow of a SPAKE protocol can send an optional payload, + // since the key exchange is already complete on the sender's side. + optional bytes payload = 4; +} diff --git a/NearDrop/ProtobufSource/offline_wire_formats.proto b/NearDrop/ProtobufSource/offline_wire_formats.proto new file mode 100644 index 0000000..c112004 --- /dev/null +++ b/NearDrop/ProtobufSource/offline_wire_formats.proto @@ -0,0 +1,403 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +package location.nearby.connections; + +option optimize_for = LITE_RUNTIME; +option java_outer_classname = "OfflineWireFormatsProto"; +option java_package = "com.google.location.nearby.connections.proto"; +option objc_class_prefix = "GNCP"; + +message OfflineFrame { + enum Version { + UNKNOWN_VERSION = 0; + V1 = 1; + } + optional Version version = 1; + + // Right now there's only 1 version, but if there are more, exactly one of + // the following fields will be set. + optional V1Frame v1 = 2; +} + +message V1Frame { + enum FrameType { + UNKNOWN_FRAME_TYPE = 0; + CONNECTION_REQUEST = 1; + CONNECTION_RESPONSE = 2; + PAYLOAD_TRANSFER = 3; + BANDWIDTH_UPGRADE_NEGOTIATION = 4; + KEEP_ALIVE = 5; + DISCONNECTION = 6; + PAIRED_KEY_ENCRYPTION = 7; + } + optional FrameType type = 1; + + // Exactly one of the following fields will be set. + optional ConnectionRequestFrame connection_request = 2; + optional ConnectionResponseFrame connection_response = 3; + optional PayloadTransferFrame payload_transfer = 4; + optional BandwidthUpgradeNegotiationFrame bandwidth_upgrade_negotiation = 5; + optional KeepAliveFrame keep_alive = 6; + optional DisconnectionFrame disconnection = 7; + optional PairedKeyEncryptionFrame paired_key_encryption = 8; +} + +message ConnectionRequestFrame { + // Should always match cs/symbol:location.nearby.proto.connections.Medium + // LINT.IfChange + enum Medium { + UNKNOWN_MEDIUM = 0; + MDNS = 1 [deprecated = true]; + BLUETOOTH = 2; + WIFI_HOTSPOT = 3; + BLE = 4; + WIFI_LAN = 5; + WIFI_AWARE = 6; + NFC = 7; + WIFI_DIRECT = 8; + WEB_RTC = 9; + BLE_L2CAP = 10; + USB = 11; + } + // LINT.ThenChange(//depot/google3/third_party/nearby/proto/connections_enums.proto) + + optional string endpoint_id = 1; + optional string endpoint_name = 2; + optional bytes handshake_data = 3; + // A random number generated for each outgoing connection that is presently + // used to act as a tiebreaker when 2 devices connect to each other + // simultaneously; this can also be used for other initialization-scoped + // things in the future. + optional int32 nonce = 4; + // The mediums this device supports upgrading to. This list should be filtered + // by both the strategy and this device's individual limitations. + repeated Medium mediums = 5; + optional bytes endpoint_info = 6; + optional MediumMetadata medium_metadata = 7; + optional int32 keep_alive_interval_millis = 8; + optional int32 keep_alive_timeout_millis = 9; + // The type of {@link Device} object. + optional int32 device_type = 10 [default = 0]; + // The bytes of serialized {@link Device} object. + optional bytes device_info = 11; +} + +message ConnectionResponseFrame { + // This doesn't need to send back endpoint_id and endpoint_name (like + // the ConnectionRequestFrame does) because those have already been + // transmitted out-of-band, at the time this endpoint was discovered. + + // One of: + // + // - ConnectionsStatusCodes.STATUS_OK + // - ConnectionsStatusCodes.STATUS_CONNECTION_REJECTED. + optional int32 status = 1 [deprecated = true]; + optional bytes handshake_data = 2; + + // Used to replace the status integer parameter with a meaningful enum item. + // Map ConnectionsStatusCodes.STATUS_OK to ACCEPT and + // ConnectionsStatusCodes.STATUS_CONNECTION_REJECTED to REJECT. + // Flag: connection_replace_status_with_response_connectionResponseFrame + enum ResponseStatus { + UNKNOWN_RESPONSE_STATUS = 0; + ACCEPT = 1; + REJECT = 2; + } + optional ResponseStatus response = 3; + optional OsInfo os_info = 4; + // A bitmask value to indicate which medium supports Multiplex transmission + // feature. Each supporting medium could utilize one bit starting from the + // least significant bit in this field. eq. BT utilizes the LSB bit which 0x01 + // means bt supports multiplex while 0x00 means not. Refer to ClientProxy.java + // for the bit usages. + optional int32 multiplex_socket_bitmask = 5; + optional int32 nearby_connections_version = 6; +} + +message PayloadTransferFrame { + enum PacketType { + UNKNOWN_PACKET_TYPE = 0; + DATA = 1; + CONTROL = 2; + } + + message PayloadHeader { + enum PayloadType { + UNKNOWN_PAYLOAD_TYPE = 0; + BYTES = 1; + FILE = 2; + STREAM = 3; + } + optional int64 id = 1; + optional PayloadType type = 2; + optional int64 total_size = 3; + optional bool is_sensitive = 4; + optional string file_name = 5; + optional string parent_folder = 6; + } + + // Accompanies DATA packets. + message PayloadChunk { + enum Flags { + LAST_CHUNK = 0x1; + } + optional int32 flags = 1; + optional int64 offset = 2; + optional bytes body = 3; + } + + // Accompanies CONTROL packets. + message ControlMessage { + enum EventType { + UNKNOWN_EVENT_TYPE = 0; + PAYLOAD_ERROR = 1; + PAYLOAD_CANCELED = 2; + PAYLOAD_RECEIVED_ACK = 3; + } + + optional EventType event = 1; + optional int64 offset = 2; + } + + optional PacketType packet_type = 1; + optional PayloadHeader payload_header = 2; + + // Exactly one of the following fields will be set, depending on the type. + optional PayloadChunk payload_chunk = 3; + optional ControlMessage control_message = 4; +} + +message BandwidthUpgradeNegotiationFrame { + enum EventType { + UNKNOWN_EVENT_TYPE = 0; + UPGRADE_PATH_AVAILABLE = 1; + LAST_WRITE_TO_PRIOR_CHANNEL = 2; + SAFE_TO_CLOSE_PRIOR_CHANNEL = 3; + CLIENT_INTRODUCTION = 4; + UPGRADE_FAILURE = 5; + CLIENT_INTRODUCTION_ACK = 6; + } + + // Accompanies UPGRADE_PATH_AVAILABLE and UPGRADE_FAILURE events. + message UpgradePathInfo { + // Should always match cs/symbol:location.nearby.proto.connections.Medium + enum Medium { + UNKNOWN_MEDIUM = 0; + MDNS = 1 [deprecated = true]; + BLUETOOTH = 2; + WIFI_HOTSPOT = 3; + BLE = 4; + WIFI_LAN = 5; + WIFI_AWARE = 6; + NFC = 7; + WIFI_DIRECT = 8; + WEB_RTC = 9; + // 10 is reserved. + USB = 11; + } + + // Accompanies Medium.WIFI_HOTSPOT. + message WifiHotspotCredentials { + optional string ssid = 1; + optional string password = 2; + optional int32 port = 3; + optional string gateway = 4 [default = "0.0.0.0"]; + // This field can be a band or frequency + optional int32 frequency = 5 [default = -1]; + } + + // Accompanies Medium.WIFI_LAN. + message WifiLanSocket { + optional bytes ip_address = 1; + optional int32 wifi_port = 2; + } + + // Accompanies Medium.BLUETOOTH. + message BluetoothCredentials { + optional string service_name = 1; + optional string mac_address = 2; + } + + // Accompanies Medium.WIFI_AWARE. + message WifiAwareCredentials { + optional string service_id = 1; + optional bytes service_info = 2; + optional string password = 3; + } + + // Accompanies Medium.WIFI_DIRECT. + message WifiDirectCredentials { + optional string ssid = 1; + optional string password = 2; + optional int32 port = 3; + optional int32 frequency = 4; + optional string gateway = 5 [default = "0.0.0.0"]; + } + + // Accompanies Medium.WEB_RTC + message WebRtcCredentials { + optional string peer_id = 1; + optional LocationHint location_hint = 2; + } + + optional Medium medium = 1; + + // Exactly one of the following fields will be set. + optional WifiHotspotCredentials wifi_hotspot_credentials = 2; + optional WifiLanSocket wifi_lan_socket = 3; + optional BluetoothCredentials bluetooth_credentials = 4; + optional WifiAwareCredentials wifi_aware_credentials = 5; + optional WifiDirectCredentials wifi_direct_credentials = 6; + optional WebRtcCredentials web_rtc_credentials = 8; + + // Disable Encryption for this upgrade medium to improve throughput. + optional bool supports_disabling_encryption = 7; + + // An ack will be sent after the CLIENT_INTRODUCTION frame. + optional bool supports_client_introduction_ack = 9; + } + + // Accompanies CLIENT_INTRODUCTION events. + message ClientIntroduction { + optional string endpoint_id = 1; + optional bool supports_disabling_encryption = 2; + } + + // Accompanies CLIENT_INTRODUCTION_ACK events. + message ClientIntroductionAck {} + + optional EventType event_type = 1; + + // Exactly one of the following fields will be set. + optional UpgradePathInfo upgrade_path_info = 2; + optional ClientIntroduction client_introduction = 3; + optional ClientIntroductionAck client_introduction_ack = 4; +} + +message KeepAliveFrame { + // And ack will be sent after receiving KEEP_ALIVE frame. + optional bool ack = 1; +} + +// Informs the remote side to immediately severe the socket connection. +// Used in bandwidth upgrades to get around a race condition, but may be used +// in other situations to trigger a faster disconnection event than waiting for +// socket closed on the remote side. +message DisconnectionFrame { + // Apply safe-to-disconnect protocol if true. + optional bool request_safe_to_disconnect = 1; + + // Ack of receiving Disconnection frame will be sent to the sender + // frame. + optional bool ack_safe_to_disconnect = 2; +} + +// A paired key encryption packet sent between devices, contains signed data. +message PairedKeyEncryptionFrame { + // The encrypted data (raw authentication token for the established + // connection) in byte array format. + optional bytes signed_data = 1; +} + +message MediumMetadata { + // True if local device supports 5GHz. + optional bool supports_5_ghz = 1; + // WiFi LAN BSSID, in the form of a six-byte MAC address: XX:XX:XX:XX:XX:XX + optional string bssid = 2; + // IP address, in network byte order: the highest order byte of the address is + // in byte[0]. + optional bytes ip_address = 3; + // True if local device supports 6GHz. + optional bool supports_6_ghz = 4; + // True if local device has mobile radio. + optional bool mobile_radio = 5; + // The frequency of the WiFi LAN AP(in MHz). Or -1 is not associated with an + // AP over WiFi, -2 represents the active network uses an Ethernet transport. + optional int32 ap_frequency = 6 [default = -1]; + // Available channels on the local device. + optional AvailableChannels available_channels = 7; + // Usable WiFi Direct client channels on the local device. + optional WifiDirectCliUsableChannels wifi_direct_cli_usable_channels = 8; + // Usable WiFi LAN channels on the local device. + optional WifiLanUsableChannels wifi_lan_usable_channels = 9; + // Usable WiFi Aware channels on the local device. + optional WifiAwareUsableChannels wifi_aware_usable_channels = 10; + // Usable WiFi Hotspot STA channels on the local device. + optional WifiHotspotStaUsableChannels wifi_hotspot_sta_usable_channels = 11; +} + +// Available channels on the local device. +message AvailableChannels { + repeated int32 channels = 1 [packed = true]; +} + +// Usable WiFi Direct client channels on the local device. +message WifiDirectCliUsableChannels { + repeated int32 channels = 1 [packed = true]; +} + +// Usable WiFi LAN channels on the local device. +message WifiLanUsableChannels { + repeated int32 channels = 1 [packed = true]; +} + +// Usable WiFi Aware channels on the local device. +message WifiAwareUsableChannels { + repeated int32 channels = 1 [packed = true]; +} + +// Usable WiFi Hotspot STA channels on the local device. +message WifiHotspotStaUsableChannels { + repeated int32 channels = 1 [packed = true]; +} + +// LocationHint is used to specify a location as well as format. +message LocationHint { + // Location is the location, provided in the format specified by format. + optional string location = 1; + + // the format of location. + optional LocationStandard.Format format = 2; +} + +message LocationStandard { + enum Format { + UNKNOWN = 0; + // E164 country codes: + // https://en.wikipedia.org/wiki/List_of_country_calling_codes + // e.g. +1 for USA + E164_CALLING = 1; + + // ISO 3166-1 alpha-2 country codes: + // https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 + ISO_3166_1_ALPHA_2 = 2; + } +} + +// Device capability for OS information. +message OsInfo { + enum OsType { + UNKNOWN_OS_TYPE = 0; + ANDROID = 1; + CHROME_OS = 2; + WINDOWS = 3; + APPLE = 4; + LINUX = 100; // g3 test environment + } + + optional OsType type = 1; +} diff --git a/NearDrop/ProtobufSource/securegcm.proto b/NearDrop/ProtobufSource/securegcm.proto new file mode 100644 index 0000000..0325f06 --- /dev/null +++ b/NearDrop/ProtobufSource/securegcm.proto @@ -0,0 +1,308 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +package securegcm; + +option optimize_for = LITE_RUNTIME; +option java_package = "com.google.security.cryptauth.lib.securegcm"; +option java_outer_classname = "SecureGcmProto"; +option objc_class_prefix = "SGCM"; + +// Message used only during enrollment +// Field numbers should be kept in sync with DeviceInfo in: +// java/com/google/security/cryptauth/backend/services/common/common.proto +message GcmDeviceInfo { + // This field's name does not match the one in DeviceInfo for legacy reasons. + // Consider using long_device_id and device_type instead when enrolling + // non-android devices. + optional fixed64 android_device_id = 1; + + // Used for device_address of DeviceInfo field 2, but for GCM capable devices. + optional bytes gcm_registration_id = 102; + + // Used for device_address of DeviceInfo field 2, but for iOS devices. + optional bytes apn_registration_id = 202; + + // Does the user have notifications enabled for the given device address. + optional bool notification_enabled = 203 [default = true]; + + // Used for device_address of DeviceInfo field 2, a Bluetooth Mac address for + // the device (e.g., to be used with EasyUnlock) + optional string bluetooth_mac_address = 302; + + // SHA-256 hash of the device master key (from the key exchange). + // Differs from DeviceInfo field 3, which contains the actual master key. + optional bytes device_master_key_hash = 103; + + // A SecureMessage.EcP256PublicKey + required bytes user_public_key = 4; + + // device's model name + // (e.g., an android.os.Build.MODEL or UIDevice.model) + optional string device_model = 7; + + // device's locale + optional string locale = 8; + + // The handle for user_public_key (and implicitly, a master key) + optional bytes key_handle = 9; + + // The initial counter value for the device, sent by the device + optional int64 counter = 12 [default = 0]; + + // The Operating System version on the device + // (e.g., an android.os.Build.DISPLAY or UIDevice.systemVersion) + optional string device_os_version = 13; + + // The Operating System version number on the device + // (e.g., an android.os.Build.VERSION.SDK_INT) + optional int64 device_os_version_code = 14; + + // The Operating System release on the device + // (e.g., an android.os.Build.VERSION.RELEASE) + optional string device_os_release = 15; + + // The Operating System codename on the device + // (e.g., an android.os.Build.VERSION.CODENAME or UIDevice.systemName) + optional string device_os_codename = 16; + + // The software version running on the device + // (e.g., Authenticator app version string) + optional string device_software_version = 17; + + // The software version number running on the device + // (e.g., Authenticator app version code) + optional int64 device_software_version_code = 18; + + // Software package information if applicable + // (e.g., com.google.android.apps.authenticator2) + optional string device_software_package = 19; + + // Size of the display in thousandths of an inch (e.g., 7000 mils = 7 in) + optional int32 device_display_diagonal_mils = 22; + + // For Authzen capable devices, their Authzen protocol version + optional int32 device_authzen_version = 24; + + // Not all devices have device identifiers that fit in 64 bits. + optional bytes long_device_id = 29; + + // The device manufacturer name + // (e.g., android.os.Build.MANUFACTURER) + optional string device_manufacturer = 31; + + // Used to indicate which type of device this is. + optional DeviceType device_type = 32 [default = ANDROID]; + + // Fields corresponding to screenlock type/features and hardware features + // should be numbered in the 400 range. + + // Is this device using a secure screenlock (e.g., pattern or pin unlock) + optional bool using_secure_screenlock = 400 [default = false]; + + // Is auto-unlocking the screenlock (e.g., when at "home") supported? + optional bool auto_unlock_screenlock_supported = 401 [default = false]; + + // Is auto-unlocking the screenlock (e.g., when at "home") enabled? + optional bool auto_unlock_screenlock_enabled = 402 [default = false]; + + // Does the device have a Bluetooth (classic) radio? + optional bool bluetooth_radio_supported = 403 [default = false]; + + // Is the Bluetooth (classic) radio on? + optional bool bluetooth_radio_enabled = 404 [default = false]; + + // Does the device hardware support a mobile data connection? + optional bool mobile_data_supported = 405 [default = false]; + + // Does the device support tethering? + optional bool tethering_supported = 406 [default = false]; + + // Does the device have a BLE radio? + optional bool ble_radio_supported = 407 [default = false]; + + // Is the device a "Pixel Experience" Android device? + optional bool pixel_experience = 408 [default = false]; + + // Is the device running in the ARC++ container on a chromebook? + optional bool arc_plus_plus = 409 [default = false]; + + // Is the value set in |using_secure_screenlock| reliable? On some Android + // devices, the platform API to get the screenlock state is not trustworthy. + // See b/32212161. + optional bool is_screenlock_state_flaky = 410 [default = false]; + + // A list of multi-device software features supported by the device. + repeated SoftwareFeature supported_software_features = 411; + + // A list of multi-device software features currently enabled (active) on the + // device. + repeated SoftwareFeature enabled_software_features = 412; + + // The enrollment session id this is sent with + optional bytes enrollment_session_id = 1000; + + // A copy of the user's OAuth token + optional string oauth_token = 1001; +} + +// This enum is used by iOS devices as values for device_display_diagonal_mils +// in GcmDeviceInfo. There is no good way to calculate it on those devices. +enum AppleDeviceDiagonalMils { + // This is the mils diagonal on an iPhone 5. + APPLE_PHONE = 4000; + // This is the mils diagonal on an iPad mini. + APPLE_PAD = 7900; +} + +// This should be kept in sync with DeviceType in: +// java/com/google/security/cryptauth/backend/services/common/common_enums.proto +enum DeviceType { + UNKNOWN = 0; + ANDROID = 1; + CHROME = 2; + IOS = 3; + BROWSER = 4; + OSX = 5; +} + +// MultiDevice features which may be supported and enabled on a device. See +enum SoftwareFeature { + UNKNOWN_FEATURE = 0; + BETTER_TOGETHER_HOST = 1; + BETTER_TOGETHER_CLIENT = 2; + EASY_UNLOCK_HOST = 3; + EASY_UNLOCK_CLIENT = 4; + MAGIC_TETHER_HOST = 5; + MAGIC_TETHER_CLIENT = 6; + SMS_CONNECT_HOST = 7; + SMS_CONNECT_CLIENT = 8; +} + +// A list of "reasons" that can be provided for calling server-side APIs. +// This is particularly important for calls that can be triggered by different +// kinds of events. Please try to keep reasons as generic as possible, so that +// codes can be re-used by various callers in a sensible fashion. +enum InvocationReason { + REASON_UNKNOWN = 0; + // First run of the software package invoking this call + REASON_INITIALIZATION = 1; + // Ordinary periodic actions (e.g. monthly master key rotation) + REASON_PERIODIC = 2; + // Slow-cycle periodic action (e.g. yearly keypair rotation???) + REASON_SLOW_PERIODIC = 3; + // Fast-cycle periodic action (e.g. daily sync for Smart Lock users) + REASON_FAST_PERIODIC = 4; + // Expired state (e.g. expired credentials, or cached entries) was detected + REASON_EXPIRATION = 5; + // An unexpected protocol failure occurred (so attempting to repair state) + REASON_FAILURE_RECOVERY = 6; + // A new account has been added to the device + REASON_NEW_ACCOUNT = 7; + // An existing account on the device has been changed + REASON_CHANGED_ACCOUNT = 8; + // The user toggled the state of a feature (e.g. Smart Lock enabled via BT) + REASON_FEATURE_TOGGLED = 9; + // A "push" from the server caused this action (e.g. a sync tickle) + REASON_SERVER_INITIATED = 10; + // A local address change triggered this (e.g. GCM registration id changed) + REASON_ADDRESS_CHANGE = 11; + // A software update has triggered this + REASON_SOFTWARE_UPDATE = 12; + // A manual action by the user triggered this (e.g. commands sent via adb) + REASON_MANUAL = 13; + // A custom key has been invalidated on the device (e.g. screen lock is + // disabled). + REASON_CUSTOM_KEY_INVALIDATION = 14; + // Periodic action triggered by auth_proximity + REASON_PROXIMITY_PERIODIC = 15; +} + +enum Type { + ENROLLMENT = 0; + TICKLE = 1; + TX_REQUEST = 2; + TX_REPLY = 3; + TX_SYNC_REQUEST = 4; + TX_SYNC_RESPONSE = 5; + TX_PING = 6; + DEVICE_INFO_UPDATE = 7; + TX_CANCEL_REQUEST = 8; + + // DEPRECATED (can be re-used after Aug 2015) + PROXIMITYAUTH_PAIRING = 10; + + // The kind of identity assertion generated by a "GCM V1" device (i.e., + // an Android phone that has registered with us a public and a symmetric + // key) + GCMV1_IDENTITY_ASSERTION = 11; + + // Device-to-device communications are protected by an unauthenticated + // Diffie-Hellman exchange. The InitiatorHello message is simply the + // initiator's public DH key, and is not encoded as a SecureMessage, so + // it doesn't have a tag. + // The ResponderHello message (which is sent by the responder + // to the initiator), on the other hand, carries a payload that is protected + // by the derived shared key. It also contains the responder's + // public DH key. ResponderHelloAndPayload messages have the + // DEVICE_TO_DEVICE_RESPONDER_HELLO tag. + DEVICE_TO_DEVICE_RESPONDER_HELLO_PAYLOAD = 12; + + // Device-to-device communications are protected by an unauthenticated + // Diffie-Hellman exchange. Once the initiator and responder + // agree on a shared key (through Diffie-Hellman), they will use messages + // tagged with DEVICE_TO_DEVICE_MESSAGE to exchange data. + DEVICE_TO_DEVICE_MESSAGE = 13; + + // Notification to let a device know it should contact a nearby device. + DEVICE_PROXIMITY_CALLBACK = 14; + + // Device-to-device communications are protected by an unauthenticated + // Diffie-Hellman exchange. During device-to-device authentication, the first + // message from initiator (the challenge) is signed and put into the payload + // of the message sent back to the initiator. + UNLOCK_KEY_SIGNED_CHALLENGE = 15; + + // Specialty (corp only) features + LOGIN_NOTIFICATION = 101; +} + +message GcmMetadata { + required Type type = 1; + optional int32 version = 2 [default = 0]; +} + +message Tickle { + // Time after which this tickle should expire + optional fixed64 expiry_time = 1; +} + +message LoginNotificationInfo { + // Time at which the server received the login notification request. + optional fixed64 creation_time = 2; + + // Must correspond to user_id in LoginNotificationRequest, if set. + optional string email = 3; + + // Host where the user's credentials were used to login, if meaningful. + optional string host = 4; + + // Location from where the user's credentials were used, if meaningful. + optional string source = 5; + + // Type of login, e.g. ssh, gnome-screensaver, or web. + optional string event_type = 6; +} diff --git a/NearDrop/ProtobufSource/securemessage.proto b/NearDrop/ProtobufSource/securemessage.proto new file mode 100644 index 0000000..5118d35 --- /dev/null +++ b/NearDrop/ProtobufSource/securemessage.proto @@ -0,0 +1,126 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Proto definitions for SecureMessage format + +syntax = "proto2"; + +package securemessage; + +option optimize_for = LITE_RUNTIME; +option java_package = "com.google.security.cryptauth.lib.securemessage"; +option java_outer_classname = "SecureMessageProto"; +option objc_class_prefix = "SMSG"; + +message SecureMessage { + // Must contain a HeaderAndBody message + required bytes header_and_body = 1; + // Signature of header_and_body + required bytes signature = 2; +} + +// Supported "signature" schemes (both symmetric key and public key based) +enum SigScheme { + HMAC_SHA256 = 1; + ECDSA_P256_SHA256 = 2; + // Not recommended -- use ECDSA_P256_SHA256 instead + RSA2048_SHA256 = 3; +} + +// Supported encryption schemes +enum EncScheme { + // No encryption + NONE = 1; + AES_256_CBC = 2; +} + +message Header { + required SigScheme signature_scheme = 1; + required EncScheme encryption_scheme = 2; + // Identifies the verification key + optional bytes verification_key_id = 3; + // Identifies the decryption key + optional bytes decryption_key_id = 4; + // Encryption may use an IV + optional bytes iv = 5; + // Arbitrary per-protocol public data, to be sent with the plain-text header + optional bytes public_metadata = 6; + // The length of some associated data this is not sent in this SecureMessage, + // but which will be bound to the signature. + optional uint32 associated_data_length = 7 [default = 0]; +} + +message HeaderAndBody { + // Public data about this message (to be bound in the signature) + required Header header = 1; + // Payload data + required bytes body = 2; +} + +// Must be kept wire-format compatible with HeaderAndBody. Provides the +// SecureMessage code with a consistent wire-format representation that +// remains stable irrespective of protobuf implementation choices. This +// low-level representation of a HeaderAndBody should not be used by +// any code outside of the SecureMessage library implementation/tests. +message HeaderAndBodyInternal { + // A raw (wire-format) byte encoding of a Header, suitable for hashing + required bytes header = 1; + // Payload data + required bytes body = 2; +} + +// ------- +// The remainder of the messages defined here are provided only for +// convenience. They are not needed for SecureMessage proper, but are +// commonly useful wherever SecureMessage might be applied. +// ------- + +// A list of supported public key types +enum PublicKeyType { + EC_P256 = 1; + RSA2048 = 2; + // 2048-bit MODP group 14, from RFC 3526 + DH2048_MODP = 3; +} + +// A convenience proto for encoding NIST P-256 elliptic curve public keys +message EcP256PublicKey { + // x and y are encoded in big-endian two's complement (slightly wasteful) + // Client MUST verify (x,y) is a valid point on NIST P256 + required bytes x = 1; + required bytes y = 2; +} + +// A convenience proto for encoding RSA public keys with small exponents +message SimpleRsaPublicKey { + // Encoded in big-endian two's complement + required bytes n = 1; + optional int32 e = 2 [default = 65537]; +} + +// A convenience proto for encoding Diffie-Hellman public keys, +// for use only when Elliptic Curve based key exchanges are not possible. +// (Note that the group parameters must be specified separately) +message DhPublicKey { + // Big-endian two's complement encoded group element + required bytes y = 1; +} + +message GenericPublicKey { + required PublicKeyType type = 1; + optional EcP256PublicKey ec_p256_public_key = 2; + optional SimpleRsaPublicKey rsa2048_public_key = 3; + // Use only as a last resort + optional DhPublicKey dh2048_public_key = 4; +} diff --git a/NearDrop/ProtobufSource/ukey.proto b/NearDrop/ProtobufSource/ukey.proto new file mode 100644 index 0000000..327d8d3 --- /dev/null +++ b/NearDrop/ProtobufSource/ukey.proto @@ -0,0 +1,105 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +package securegcm; + +option optimize_for = LITE_RUNTIME; +option java_package = "com.google.security.cryptauth.lib.securegcm"; +option java_outer_classname = "UkeyProto"; + +message Ukey2Message { + enum Type { + UNKNOWN_DO_NOT_USE = 0; + ALERT = 1; + CLIENT_INIT = 2; + SERVER_INIT = 3; + CLIENT_FINISH = 4; + } + + optional Type message_type = 1; // Identifies message type + optional bytes message_data = 2; // Actual message, to be parsed according to + // message_type +} + +message Ukey2Alert { + enum AlertType { + // Framing errors + BAD_MESSAGE = 1; // The message could not be deserialized + BAD_MESSAGE_TYPE = 2; // message_type has an undefined value + INCORRECT_MESSAGE = 3; // message_type received does not correspond to + // expected type at this stage of the protocol + BAD_MESSAGE_DATA = 4; // Could not deserialize message_data as per + // value inmessage_type + + // ClientInit and ServerInit errors + BAD_VERSION = 100; // version is invalid; server cannot find + // suitable version to speak with client. + BAD_RANDOM = 101; // Random data is missing or of incorrect + // length + BAD_HANDSHAKE_CIPHER = 102; // No suitable handshake ciphers were found + BAD_NEXT_PROTOCOL = 103; // The next protocol is missing, unknown, or + // unsupported + BAD_PUBLIC_KEY = 104; // The public key could not be parsed + + // Other errors + INTERNAL_ERROR = 200; // An internal error has occurred. error_message + // may contain additional details for logging + // and debugging. + } + + optional AlertType type = 1; + optional string error_message = 2; +} + +enum Ukey2HandshakeCipher { + RESERVED = 0; + P256_SHA512 = 100; // NIST P-256 used for ECDH, SHA512 used for + // commitment + CURVE25519_SHA512 = 200; // Curve 25519 used for ECDH, SHA512 used for + // commitment +} + +message Ukey2ClientInit { + optional int32 version = 1; // highest supported version for rollback + // protection + optional bytes random = 2; // random bytes for replay/reuse protection + + // One commitment (hash of ClientFinished containing public key) per supported + // cipher + message CipherCommitment { + optional Ukey2HandshakeCipher handshake_cipher = 1; + optional bytes commitment = 2; + } + repeated CipherCommitment cipher_commitments = 3; + + // Next protocol that the client wants to speak. + optional string next_protocol = 4; +} + +message Ukey2ServerInit { + optional int32 version = 1; // highest supported version for rollback + // protection + optional bytes random = 2; // random bytes for replay/reuse protection + + // Selected Cipher and corresponding public key + optional Ukey2HandshakeCipher handshake_cipher = 3; + optional bytes public_key = 4; +} + +message Ukey2ClientFinished { + optional bytes public_key = 1; // public key matching selected handshake + // cipher +} diff --git a/NearDrop/ProtobufSource/wire_format.proto b/NearDrop/ProtobufSource/wire_format.proto new file mode 100644 index 0000000..6853e22 --- /dev/null +++ b/NearDrop/ProtobufSource/wire_format.proto @@ -0,0 +1,236 @@ +// Copyright 2020 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Brought from: //depot/google3/location/nearby/sharing/proto/wire_format.proto +// At CL 317565061 + +syntax = "proto2"; + +package sharing.nearby; + +// Required in Chrome. +option optimize_for = LITE_RUNTIME; + +// File metadata. Does not include the actual bytes of the file. +// NEXT_ID=6 +message FileMetadata { + enum Type { + UNKNOWN = 0; + IMAGE = 1; + VIDEO = 2; + APP = 3; + AUDIO = 4; + } + + // The human readable name of this file (eg. 'Cookbook.pdf'). + optional string name = 1; + + // The type of file (eg. 'IMAGE' from 'dog.jpg'). Specifying a type helps + // provide a richer experience on the receiving side. + optional Type type = 2 [default = UNKNOWN]; + + // The FILE payload id that will be sent as a follow up containing the actual + // bytes of the file. + optional int64 payload_id = 3; + + // The total size of the file. + optional int64 size = 4; + + // The mimeType of file (eg. 'image/jpeg' from 'dog.jpg'). Specifying a + // mimeType helps provide a richer experience on receiving side. + optional string mime_type = 5 [default = "application/octet-stream"]; + + // A uuid for the attachment. Should be unique across all attachments. + optional int64 id = 6; +} + +// NEXT_ID=5 +message TextMetadata { + enum Type { + UNKNOWN = 0; + TEXT = 1; + // Open with browsers. + URL = 2; + // Open with map apps. + ADDRESS = 3; + // Dial. + PHONE_NUMBER = 4; + } + + // The title of the text content. + optional string text_title = 2; + + // The type of text (phone number, url, address, or plain text). + optional Type type = 3 [default = UNKNOWN]; + + // The BYTE payload id that will be sent as a follow up containing the actual + // bytes of the text. + optional int64 payload_id = 4; + + // The size of the text content. + optional int64 size = 5; + + // A uuid for the attachment. Should be unique across all attachments. + optional int64 id = 6; +} + +// NEXT_ID=5 +message WifiCredentialsMetadata { + enum SecurityType { + UNKNOWN_SECURITY_TYPE = 0; + OPEN = 1; + WPA_PSK = 2; + WEP = 3; + } + + // The Wifi network name. This will be sent in introduction. + optional string ssid = 2; + + // The security type of network (OPEN, WPA_PSK, WEP). + optional SecurityType security_type = 3 [default = UNKNOWN_SECURITY_TYPE]; + + // The BYTE payload id that will be sent as a follow up containing the + // password. + optional int64 payload_id = 4; + + // A uuid for the attachment. Should be unique across all attachments. + optional int64 id = 5; +} + +// A frame used when sending messages over the wire. +// NEXT_ID=3 +message Frame { + enum Version { + UNKNOWN_VERSION = 0; + V1 = 1; + } + optional Version version = 1; + + // Right now there's only 1 version, but if there are more, exactly one of + // the following fields will be set. + optional V1Frame v1 = 2; +} + +// NEXT_ID=7 +message V1Frame { + enum FrameType { + UNKNOWN_FRAME_TYPE = 0; + INTRODUCTION = 1; + RESPONSE = 2; + PAIRED_KEY_ENCRYPTION = 3; + PAIRED_KEY_RESULT = 4; + CERTIFICATE_INFO = 5; + CANCEL = 6; + } + + optional FrameType type = 1; + + // Exactly one of the following fields will be set. + optional IntroductionFrame introduction = 2; + optional ConnectionResponseFrame connection_response = 3; + optional PairedKeyEncryptionFrame paired_key_encryption = 4; + optional PairedKeyResultFrame paired_key_result = 5; + optional CertificateInfoFrame certificate_info = 6; +} + +// An introduction packet sent by the sending side. Contains a list of files +// they'd like to share. +// NEXT_ID=4 +message IntroductionFrame { + repeated FileMetadata file_metadata = 1; + repeated TextMetadata text_metadata = 2; + // The required app package to open the content. May be null. + optional string required_package = 3; + repeated WifiCredentialsMetadata wifi_credentials_metadata = 4; +} + +// A response packet sent by the receiving side. Accepts or rejects the list of +// files. +// NEXT_ID=2 +message ConnectionResponseFrame { + enum Status { + UNKNOWN = 0; + ACCEPT = 1; + REJECT = 2; + NOT_ENOUGH_SPACE = 3; + UNSUPPORTED_ATTACHMENT_TYPE = 4; + TIMED_OUT = 5; + } + + // The receiving side's response. + optional Status status = 1; +} + +// A paired key encryption packet sent between devices, contains signed data. +// NEXT_ID=3 +message PairedKeyEncryptionFrame { + // The encrypted data in byte array format. + optional bytes signed_data = 1; + + // The hash of a certificate id. + optional bytes secret_id_hash = 2; + + // An optional encrypted data in byte array format. + optional bytes optional_signed_data = 3; +} + +// A paired key verification result packet sent between devices. +// NEXT_ID=2 +message PairedKeyResultFrame { + enum Status { + UNKNOWN = 0; + SUCCESS = 1; + FAIL = 2; + UNABLE = 3; + } + + // The verification result. + optional Status status = 1; +} + +// A package containing certificate info to be shared to remote device offline. +// NEXT_ID=2 +message CertificateInfoFrame { + // The public certificates to be shared with remote devices. + repeated PublicCertificate public_certificate = 1; +} + +// A public certificate from the local device. +// NEXT_ID=8 +message PublicCertificate { + // The unique id of the public certificate. + optional bytes secret_id = 1; + + // A bytes representation of a Secret Key owned by contact, to decrypt the + // metadata_key stored within the advertisement. + optional bytes authenticity_key = 2; + + // A bytes representation a public key of X509Certificate, owned by contact, + // to decrypt encrypted UKEY2 (from Nearby Connections API) as a hand shake in + // contact verification phase. + optional bytes public_key = 3; + + // The time in millis from epoch when this certificate becomes effective. + optional int64 start_time = 4; + + // The time in millis from epoch when this certificate expires. + optional int64 end_time = 5; + + // The encrypted metadata in bytes, contains personal information of the + // device/user who created this certificate. Needs to be decrypted into bytes, + // and converted back to EncryptedMetadata object to access fields. + optional bytes encrypted_metadata_bytes = 6; + + // The tag for verifying metadata_encryption_key. + optional bytes metadata_encryption_key_tag = 7; +} + +// NEXT_ID=3 +message WifiCredentials { + // Wi-Fi password. + optional string password = 1; + // True if the network is a hidden network that is not broadcasting its SSID. + // Default is false. + optional bool hidden_ssid = 2 [default = false]; +} \ No newline at end of file diff --git a/NearDrop/ru.lproj/Localizable.strings b/NearDrop/ru.lproj/Localizable.strings new file mode 100644 index 0000000..c943dae Binary files /dev/null and b/NearDrop/ru.lproj/Localizable.strings differ diff --git a/NearDrop/ru.lproj/Localizable.stringsdict b/NearDrop/ru.lproj/Localizable.stringsdict new file mode 100644 index 0000000..2cdb428 --- /dev/null +++ b/NearDrop/ru.lproj/Localizable.stringsdict @@ -0,0 +1,26 @@ + + + + + NFiles + + NSStringLocalizedFormatKey + %#@files@ + files + + NSStringFormatSpecTypeKey + NSStringPluralRuleType + NSStringFormatValueTypeKey + d + one + %d файл + few + %d файла + many + %d файлов + other + %d файлов + + + + diff --git a/PROTOCOL.md b/PROTOCOL.md new file mode 100644 index 0000000..38728ec --- /dev/null +++ b/PROTOCOL.md @@ -0,0 +1,196 @@ +# Google's Nearby Share protocol + +This document describes the Nearby Share protocol as understood by me (@grishka) from Chromium sources (that are way too convoluted) and decompiled Google Services Framework apk (that, despite being a decompilation of obfuscated code, is still more helpful than Chromium sources). + +The protocol is peer-to-peer, end-to-end encrypted. Overall, it appears like it was mostly designed to run over an unreliable medium like UDP, but I've only observed it over TCP. + +Only the WiFi LAN protocol is described here because that's what I reverse engineered, but the data running over other mediums (Bluetooth, WiFi Direct, ...) is most probably largely the same. + +If you want to build your own Nearby Share *thing*, you will need: + +1. An implementation of multicast DNS (most modern OSes have it built-in) +2. A cryptography library that is capable of ECDSA key exchange, AES-CBC, HMAC, and SHA256. OpenSSL will do but is definitely an overkill. +3. A Protobuf library +4. [These Protobuf files](/NearDrop/ProtobufSource) I collected from the Chromium sources so you don't have to + +It is also very helpful to read logcat on your Android device if you're having any trouble. The logging of the Android implementation of Nearby Share is very verbose. + +### Device roles + +Since a file transfer is unidirectional, the peers are assigned roles: + +* The receiving side is the **server**. It listens on a TCP port and advertises an MDNS service. +* The sending side is the **client**. It discovers the MDNS service and connects to the server's TCP port. + +### How devices find each other + +To become visible in the sheet on Android devices, a *server* advertises an MDNS service. The **domain** is empty. The **type** is `_FC9F5ED42C8A._tcp.`. The **port** is an arbitrary TCP port on which the server accepts incoming connections. + +The **name** is the following 10 bytes encoded in URL-safe base64: + +* `0x23`, Google calls this "PCP" but I have no idea what it is +* 4-byte **endpoint ID** +* 3-byte **service ID**: `0xFC, 0x9F, 0x5E` +* 2 zero bytes that serve an unknown purpose + +The **endpoint ID** is 4 random alphanumeric characters. It identifies devices to each other. Android uses it in its logs quite extensively. + +The service also needs to have a TXT record with key `n` and the value of the following encoded in URL-safe base64 ("endpoint info"): + +* 1 byte: bit field + * 3 bits: version, set to 0 + * 1 bit: visibility, 0 = visible + * 3 bits: device type. Android uses this to pick an icon. 0 = unknown, 1 = phone, 2 = tablet, 3 = laptop + * 1 bit: reserved, set to 0 +* 16 bytes of unknown purpose. I set them to random. +* User-visible device name in UTF-8, prefixed with 1-byte length. + +Android does not advertise the MDNS service all the time regardless of the visibility setting. It waits for some kind of signal to start it and also show the "A device nearby is sharing" notification. As of now, it is unknown what exactly is it that it's waiting for. Probably a broadcast packet of some kind over either WiFi or Bluetooth. + +The service ID (FC9F...) comes from SHA256("NearbySharing") = `fc9f5ed42c8a5e9e94684076ef3bf938a809c60ad354992b0435aebbdc58b97b`. + +### High-level diagram + +```mermaid +sequenceDiagram + Client-->>Server: (Connects to advertised TCP port) + Client->>Server: Connection request + Client->>Server: UKEY2 ClientInit + Server->>Client: UKEY2 ServerInit + Client->>Server: UKEY2 ClientFinish + Client->>Server: Connection response + Note over Server, Client: All following packets are encrypted + Server->>Client: Paired key encryption + Client->>Server: Paired key encryption + Server->>Client: Paired key result + Client->>Server: Paired key result + Client->>Server: Introduction (transfer metadata) + Note over Server: Asks the user + Server->>Client: Response (accept/reject) + Client->>Server: File chunks + Client-->>Server: + Client-->>Server: + Client->>Server: Disconnection + Client-->Server: (Close TCP connection) +``` + +From the Google point of view, the "Nearby connections" part is a separate universal transport layer, over which the "Share" runs. This may explain some bizarre arrangements where you have protobuf inside protobuf inside encrypted protobuf inside protobuf. + +### Frame/packet/message types + +There are three types of packets that can appear directly ~~on the wire~~ in the air: + +1. **Offline frames.** These are the basic uint of the nearby protocol. They are used to control the connection. +2. **UKEY2 messages.** These are used for the encryption key exchange (UKEY2 is Google's bespoke algorithm for that). +3. **Secure messages.** These are used exclusively after the initial negotiation and carry other packets inside them in the encrypted form. + +Keep the protobuf files open to follow along. + +### TCP framing + +Each protobuf message sent over the TCP connection is prefixed with 4-byte big-endian (MSB first) length. + +### Initial handshake & key exchange + +(described from the server/recipient point of view) + +After the client connects to the server, it sends two packets: a "connection request" and a "UKEY2 client init". + +#### Connection request + +This is a subtype of "offline frame". +The client wants to connect to the server and tells it about itself. The only field of interest here is `endpointInfo`. It contains the device type and name. It has the same format as the `n` TXT record described above, just without the base64 encoding. + +#### UKEY2 client init + +This is a subtype of "UKEY2 message". Google's UKEY2 reference implementation [is open source](https://github.com/google/ukey2) and comes with documentation. Please refer to that repo for details on the key exchange. +This is the initial step of the key exchange for end-to-end encryption. Upon receiving this, the server generates a ECDSA key pair and sends its public key in a "server init". The server also needs to remember the raw serialized client init message for the final key derivation step. The outgoing server init message is also needed for the next step. The bytes include the entire protobuf message but do not include the int32 length prefix. + +After receiving the server init, the client completes the key derivation and sends a "client finish", containing its public key. + +#### UKEY2 client finish + +This is where the server completes the key derivation. This step is described in detail [in the Google readme](https://github.com/google/ukey2#deriving-the-authentication-string-and-the-next-protocol-secret). + +The result of the key exchange is two values: the authentication string and the next protocol secret. + +The **next protocol secret** is further processed to obtain the two 32-byte AES and two 32-byte HMAC keys used for encryption and authentication of further communications ([relevant Chromium code](https://source.chromium.org/chromium/chromium/src/+/main:third_party/securemessage/src/cpp/src/securemessage/crypto_ops.cc) and [this as well](https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:third_party/ukey2/src/src/main/cpp/src/securegcm/d2d_crypto_ops.cc)): + +Derive two 32-byte "device to device" keys using HKDF-SHA256: + +* **D2D client key**, using the **next protocol secret** for input key material, `82AA55A0D397F88346CA1CEE8D3909B95F13FA7DEB1D4AB38376B8256DA85510` for salt, and the string `client` for info +* **D2D cerver key**, using the same parameters, except **info** is `server` + +Next, derive the four keys you will use for the actual encryption. All four use the same value of salt, which is `SHA256("SecureMessage")`, or `BF9D2A53C63616D75DB0A7165B91C1EF73E537F2427405FA23610A4BE657642E`. These keys are from the server POV; if you're the client, they need to be swapped around (decrypt/receive shoud use the server key and vice versa). + +* **Decrypt key**: IKM = D2D client key, info = `ENC:2` +* **Receive HMAC key**: IKM = D2D client key, info = `SIG:1` +* **Encrypt key**: IKM = D2D server key, info = `ENC:2` +* **Send HMAC key**: IKM = D2D server key, info = `SIG:1` + +The key exchange is now complete. + +The **authentication string** is used for out-of-band key verification. Nearby Share doesn't use the algorithm specified by UKEY2. Instead, a 4-digit PIN code is generated using [this algorithm](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/nearby_sharing/nearby_sharing_service_impl.cc;l=215-230;drc=9468ba955b5794fdfaa7301fce4fb70940830c88). + +#### Connection response + +After the key exchange is complete, the client sends one last plaintext message to the server: a connection response. It's a subtype of offline frame saying that the client has accepted the connection (the connection it itself initiated... whatever). All the following communication is encrypted and wrapped in the payload layer. + +### The encryption layer + +The message type on the wire is always the "secure message". A secure message has two fields: header and body, and the signature. + +Header and body is a serialized `HeaderAndBody` message. Inside, there are two fields, that are (what a surprise!) header and body. The body contains the encrypted payload. The header contains the encryption scheme (must be set to `AES256_CBC`), the signature scheme (must be set to `HMAC_SHA256`), the IV (initialization vector) for AES-CBC consisting of 16 random bytes, and the public metadata. Public metadata is needed because the protocol is extensible af. It contains two fields with constant values: version that is always 1 and type that is always `DEVICE_TO_DEVICE_MESSAGE`. + +The signature is a HMAC-SHA256 of the header-and-body fields using one of the keys derived above. + +The body inside header-and-body is encrypted using AES-CBC with PKCS7 padding. After decryption it should be a valid device to device message (see securegcm.proto). If it isn't, you did something wrong. Go back and debug your key exchange code. Cryptography is messy, don't worry, no one gets it right on the first try ¯\\\_(ツ)_/¯ + +The device to device message contains a sequence number and a message. The message is always a serialized offline frame. The sequence number starts at 0 and is incremented with each message. Client and server have their own independent sequence numbers. + +### The payload layer + +![yo dawg, I heard you like protobuf...](/images/YoDawg.jpg) + +This layer allows the transfer of arbitrarily large payloads in chunks. Payloads come in two types: bytes and files. All negotiation uses bytes payloads with protobuf messages inside. The file payloads are used for actual files. + +Payload transfer frames are wrapped into offline frames of type `PAYLOAD_TRANSFER`. These are then encrypted as described above. Meaning of the important payload transfer frame fields is as follows: + +* **header**: the metadata + * **id**: the payload identifier within the connection. Allows transferring multiple payloads in parallel. You use it to keep track of multiple transfers, associate buffers and files to it, etc. + * **type**: either `BYTES` or `FILE` + * **totalSize**: self-explanatory +* **chunk**: the data itself + * **offset**: the offset at which this chunk needs to be written into the buffer or file + * **flags**: if `LAST_CHUNK` (bit 0) is set, the transfer is complete and this is the last chunk + * **body**: the data bytes themselves + +Android does this thing where it sends 2 payload transfer frames in succession for each negotiation message: the first contains the entire message, the second contains 0 bytes but has the `LAST_CHUNK` flag set. I replicated this behavior in NearDrop. + +### The "paired key encryption", whatever that is + +The client and the server send each other a "paired key encryption" frame, wrapped into the payload layer. *Presumably*, this is used for all the visibility-restriction phone number stuff. Also presumably getting the data contained within involves talking to Google servers. I set `secretIDHash` to 6 random bytes and `signedData` to 72 random bytes in the ones I send. It works fine. + +After that, the client and the server send each other a "paired key result" frame. Both have `status` set to `UNABLE`. Whatever. + +These and following protobuf messages are specific to Nearby Share and [are defined here](/NearDrop/ProtobufSource/wire_format.proto). + +### The transfer metadata aka introduction + +After the successful exchange of the meaningless paired key encryption frames, the client sends an "introduction" frame to the server. This contains the list of files that the client is about to send to the server. The fields should be self-explanatory. The `payload_id` will be used in the payload layer for transferring that particluar file. + +At this point, Android shows that the connection was successful and displays the PIN code. The server would prompt the user to accept the transfer. + +### The file transfer + +#### Accepting the transfer + +To accept the transfer, the server sends a "response" frame with `status` set to `ACCEPT`. The client will then start sending file chunks over the payload layer. You did it 🎉 + +#### Rejecting the transfer + +Do the same but set `status` to `REJECT`. There are also other status codes, like `NOT_ENOUGH_SPACE`, that result in Android showing a different error. + +### Keep-alive frames + +Android sends offline frames of type `KEEP_ALIVE` every 10 seconds and expects the server to do the same. If you don't, it will terminate the connection after a while thinking your app crashed or something. This especially comes into play when sending large files. No, TCP's built-in acknowledgements are not enough. There are so many abstraction layers that whoever came up with this forgot about them. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec937d3 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +**NearDrop** is a partial implementation of [Google's Nearby Share](https://blog.google/products/android/nearby-share/) for macOS. + +[Protocol documentation](/PROTOCOL.md) is available separately. + +The app lives in your menu bar and saves files to your downloads folder. It's that simple, really. + +## Limitations + +* **Receive only**. For now. I haven't yet figured out how to make Android turn on the MDNS service and/or show the "a device nearby is sharing" notification. +* **Wi-Fi LAN only**. Your Android device and your Mac need to be on the same network for this app to work. Google's implementation supports multiple mediums, including Wi-Fi Direct, Wi-Fi hotspot, Bluetooth, some kind of 5G peer-to-peer connection, and even a WebRTC-based protocol that goes over the internet through Google servers. Wi-Fi direct isn't supported on macOS (Apple has their own, incompatible, AWDL thing, used in AirDrop). Bluetooth needs further reverse engineering. + +## Installation + +Download the latest build from the releases section, unzip, move to your applications folder. Do the usual Gatekeeper thing to run an Apple-untrusted app for the first time. If you want the app to start on boot, add it manually to login objects in System Preferences. + +## FAQ + +#### Why is the app not notarized? + +Because I don't want to pay Apple $99 a year for the privilege of developing macOS apps and oppose their idea of security. + +#### Why is this not on the app store? + +Because I don't want to pay Apple $99 a year for the privilege of developing macOS apps. I also don't want to have to go through the review process. + +#### Why not the other way around, i.e. AirDrop on Android? + +While I am an Android developer, and I have looked into this, this is nigh-impossible. AirDrop uses [AWDL](https://stackoverflow.com/questions/19587701/what-is-awdl-apple-wireless-direct-link-and-how-does-it-work), Apple's own proprietary take on peer-to-peer Wi-Fi. This works on top of 802.11 itself, the low-level Wi-Fi protocol, and thus can not be implemented without messing around with the Wi-Fi adapter drivers and raw packets and all that. It might be possible on Android, but it would at the very least require root and possibly a custom kernel. There is [an open-source implementation of AWDL and AirDrop for Linux](https://owlink.org/code/). diff --git a/images/YoDawg.jpg b/images/YoDawg.jpg new file mode 100644 index 0000000..b7e34bf Binary files /dev/null and b/images/YoDawg.jpg differ