├── SSHCore ├── en.lproj │ ├── InfoPlist.strings │ ├── SSHCoreViewController.xib │ └── MainWindow.xib ├── libgcrypt.a ├── libssh2.a ├── libgpg-error.a ├── SSHCore-Prefix.pch ├── SSHCoreViewController.h ├── main.m ├── SSHCoreAppDelegate.h ├── SSHCore-Info.plist ├── simulator.m ├── SSHCore.h ├── SSHCoreViewController.m ├── SSHCoreAppDelegate.m ├── libssh2_publickey.h ├── libssh2_config.h ├── SSHCore.m ├── libssh2_sftp.h └── libssh2.h ├── SSHCoreTests ├── en.lproj │ └── InfoPlist.strings ├── SSHCoreTests-Prefix.pch ├── SSHCoreTests.h ├── SSHCoreTests.m └── SSHCoreTests-Info.plist ├── .gitignore ├── SSHCore.xcodeproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── project.pbxproj ├── readme.markdown └── library-build-notes.txt /SSHCore/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /SSHCore/libgcrypt.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhagan/SSHCore/HEAD/SSHCore/libgcrypt.a -------------------------------------------------------------------------------- /SSHCore/libssh2.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhagan/SSHCore/HEAD/SSHCore/libssh2.a -------------------------------------------------------------------------------- /SSHCoreTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /SSHCore/libgpg-error.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lhagan/SSHCore/HEAD/SSHCore/libgpg-error.a -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .DS_Store 3 | build 4 | *.log 5 | *.log.* 6 | logs 7 | .sass-cache 8 | *~ 9 | ~* 10 | *.pbxuser 11 | *.mode1v3 12 | xcuserdata 13 | -------------------------------------------------------------------------------- /SSHCoreTests/SSHCoreTests-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SSHCoreTests' target in the 'SSHCoreTests' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /SSHCore.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SSHCoreTests/SSHCoreTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // SSHCoreTests.h 3 | // SSHCoreTests 4 | // 5 | // This file is part of SSHCore 6 | // See https://github.com/lhagan/SSHCore for more information 7 | // Copyright (c) 2010-2011 Luke D Hagan 8 | // 9 | 10 | #import 11 | 12 | 13 | @interface SSHCoreTests : SenTestCase { 14 | @private 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /SSHCore/SSHCore-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'SSHCore' target in the 'SSHCore' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /SSHCore/SSHCoreViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // SSHCoreViewController.h 3 | // SSHCore 4 | // 5 | // This file is part of SSHCore 6 | // See https://github.com/lhagan/SSHCore for more information 7 | // Copyright (c) 2010-2011 Luke D Hagan 8 | // 9 | 10 | #import 11 | 12 | @interface SSHCoreViewController : UIViewController { 13 | 14 | IBOutlet UITextView *viewText; 15 | 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /SSHCore/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SSHCore 4 | // 5 | // This file is part of SSHCore 6 | // See https://github.com/lhagan/SSHCore for more information 7 | // Copyright (c) 2010-2011 Luke D Hagan 8 | // 9 | 10 | #import 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 15 | int retVal = UIApplicationMain(argc, argv, nil, nil); 16 | [pool release]; 17 | return retVal; 18 | } 19 | -------------------------------------------------------------------------------- /SSHCore/SSHCoreAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SSHCoreAppDelegate.h 3 | // SSHCore 4 | // 5 | // This file is part of SSHCore 6 | // See https://github.com/lhagan/SSHCore for more information 7 | // Copyright (c) 2010-2011 Luke D Hagan 8 | // 9 | 10 | #import 11 | 12 | @class SSHCoreViewController; 13 | 14 | @interface SSHCoreAppDelegate : NSObject { 15 | 16 | } 17 | 18 | @property (nonatomic, retain) IBOutlet UIWindow *window; 19 | 20 | @property (nonatomic, retain) IBOutlet SSHCoreViewController *viewController; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /SSHCoreTests/SSHCoreTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SSHCoreTests.m 3 | // SSHCoreTests 4 | // 5 | // This file is part of SSHCore 6 | // See https://github.com/lhagan/SSHCore for more information 7 | // Copyright (c) 2010-2011 Luke D Hagan 8 | // 9 | 10 | #import "SSHCoreTests.h" 11 | 12 | 13 | @implementation SSHCoreTests 14 | 15 | - (void)setUp 16 | { 17 | [super setUp]; 18 | 19 | // Set-up code here. 20 | } 21 | 22 | - (void)tearDown 23 | { 24 | // Tear-down code here. 25 | 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | STFail(@"Unit tests are not implemented yet in SSHCoreTests"); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /SSHCoreTests/SSHCoreTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.joviancore.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SSHCore/SSHCore-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.joviancore.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | NSMainNibFile 30 | MainWindow 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /SSHCore/simulator.m: -------------------------------------------------------------------------------- 1 | // 2 | // hack to fix libssh2 issues in iPhone Simulator 3 | // 4 | 5 | #import 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | DIR * opendir$INODE64$UNIX2003( char * dirName ) 14 | { 15 | return opendir( dirName ); 16 | } 17 | 18 | struct dirent * readdir$INODE64( DIR * dir ) 19 | { 20 | return readdir( dir ); 21 | } 22 | 23 | BOOL closedir$UNIX2003( DIR * dir ) 24 | { 25 | return closedir( dir ); 26 | } 27 | 28 | int fnmatch$UNIX2003( const char * pattern, const char * string, int flags ) 29 | { 30 | return fnmatch( pattern, string, flags ); 31 | } 32 | 33 | int write$UNIX2003( const void * buffer, size_t size, size_t count, FILE * stream ) 34 | { 35 | return fwrite( buffer, size, count, stream ); 36 | } 37 | 38 | FILE * fopen$UNIX2003( const char * fname, const char * mode ) 39 | { 40 | return fopen( fname, mode ); 41 | } 42 | 43 | FILE * open$UNIX2003( const char * fname, int mode ) 44 | { 45 | return ( FILE * ) open( fname, mode ); 46 | } 47 | 48 | int read$UNIX2003( FILE * fd, char * buffer, unsigned int n ) 49 | { 50 | return read( ( int ) fd, buffer, n ); 51 | } 52 | 53 | int close$UNIX2003( FILE * fd ) 54 | { 55 | return close( ( int ) fd ); 56 | } 57 | 58 | int stat$INODE64( const char * pcc, struct stat * pss ) 59 | { 60 | return stat( pcc, pss ); 61 | } 62 | 63 | int fcntl$UNIX2003( int fildes, int cmd, int one ) 64 | { 65 | return fcntl( fildes, cmd, one ); 66 | } 67 | 68 | int fstat$INODE64( int filedes, struct stat * buf ) 69 | { 70 | return fstat( filedes, buf ); 71 | } 72 | 73 | ssize_t pread$UNIX2003( int fildes, void *buf, size_t nbyte, off_t offset ) 74 | { 75 | return pread( fildes, buf, nbyte, offset ); 76 | } 77 | 78 | ssize_t send$UNIX2003(int s, const void *msg, size_t len, int flags) 79 | { 80 | return send ( s, msg, len, flags); 81 | } 82 | 83 | ssize_t recv$UNIX2003(int s, void *msg, int len, int flags) 84 | { 85 | return recv ( s, msg, len, flags); 86 | } 87 | 88 | int select$UNIX2003(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) 89 | { 90 | return select ( nfds, readfds, writefds, errorfds, timeout); 91 | } 92 | 93 | clock_t clock$UNIX2003( void ) 94 | { 95 | return clock (); 96 | } -------------------------------------------------------------------------------- /SSHCore/SSHCore.h: -------------------------------------------------------------------------------- 1 | /* SSHCore Framework - a Cocoa wrapper for libssh2 2 | * 3 | * Revision History: 4 | * 0.1.0 - 2011-05-31 - heavily reworked to work on iPhone 5 | * 0.0.1 - 2010-04-03 - proof of concept 6 | * 7 | * 8 | * Copyright (c) 2010-2011 Luke D Hagan 9 | * All rights reserved. 10 | * 11 | * Includes a copy of libssh2, an open-source library released 12 | * under the BSD licence. libssh2 is copyright the libssh2 team 13 | * and respective authors. See http://www.libssh2.org for more 14 | * information. 15 | * 16 | * Redistribution and use in source and binary forms, 17 | * with or without modification, are permitted provided 18 | * that the following conditions are met: 19 | * 20 | * Redistributions of source code must retain the above 21 | * copyright notice, this list of conditions and the 22 | * following disclaimer. 23 | * 24 | * Redistributions in binary form must reproduce the above 25 | * copyright notice, this list of conditions and the following 26 | * disclaimer in the documentation and/or other materials 27 | * provided with the distribution. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 30 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 31 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 32 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 34 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 36 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 37 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 38 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 39 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 40 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 41 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 42 | * OF SUCH DAMAGE. 43 | */ 44 | 45 | #import 46 | 47 | 48 | @interface ssh : NSObject { 49 | const char *hostname; 50 | int port; 51 | const char *username; 52 | const char *password; 53 | const char *key; 54 | const char *keypub; 55 | } 56 | 57 | -(int) initWithHost:(NSString*)host port:(int) p user:(NSString*)user key:(NSString*)k keypub:(NSString*)kpub password:(NSString*)pass; 58 | -(NSString*) execCommand: (NSString*)commandline; 59 | -(int) closeSSH; 60 | 61 | -(void) libssh2ver; 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /SSHCore/SSHCoreViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // SSHCoreViewController.m 3 | // SSHCore 4 | // 5 | // This file is part of SSHCore 6 | // See https://github.com/lhagan/SSHCore for more information 7 | // Copyright (c) 2010-2011 Luke D Hagan 8 | // 9 | 10 | #import "SSHCoreViewController.h" 11 | #import "SSHCore.h" 12 | 13 | @implementation SSHCoreViewController 14 | 15 | - (void)dealloc 16 | { 17 | [viewText release]; 18 | [super dealloc]; 19 | } 20 | 21 | - (void)didReceiveMemoryWarning 22 | { 23 | // Releases the view if it doesn't have a superview. 24 | [super didReceiveMemoryWarning]; 25 | 26 | // Release any cached data, images, etc that aren't in use. 27 | } 28 | 29 | #pragma mark - View lifecycle 30 | 31 | 32 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 33 | - (void)viewDidLoad 34 | { 35 | [super viewDidLoad]; 36 | 37 | // output string for UITextView 38 | NSString *output = @""; 39 | 40 | // create an ssh object 41 | ssh *myssh = [[ssh alloc] init]; 42 | 43 | // log in to server using password auth 44 | // note: leave password blank for key-based auth 45 | [myssh initWithHost: @"192.168.0.100" 46 | port: 22 47 | user: @"user" 48 | key: @"" 49 | keypub: @"" 50 | password: @"password"]; 51 | 52 | // execute command on server 53 | NSString *command = @"uptime"; 54 | NSString *result = [myssh execCommand: command]; 55 | 56 | // log results to console 57 | NSLog(@"%@", command); 58 | NSLog(@"%@", result); 59 | 60 | // generate rudimentary output string for UITextView 61 | output = [output stringByAppendingString: command]; 62 | output = [output stringByAppendingString: @"\r\n----------------\r\n"]; 63 | 64 | // minimal handling of connection failures, etc 65 | if (result != nil) { 66 | output = [output stringByAppendingString: result]; 67 | } else { 68 | output = [output stringByAppendingString: @"server returned null"]; 69 | }; 70 | 71 | // set UITextView to the output string 72 | viewText.text = output; 73 | 74 | // close SSH connection & release object 75 | [myssh closeSSH]; 76 | [myssh release]; 77 | 78 | } 79 | 80 | 81 | - (void)viewDidUnload 82 | { 83 | [super viewDidUnload]; 84 | // Release any retained subviews of the main view. 85 | // e.g. self.myOutlet = nil; 86 | } 87 | 88 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 89 | { 90 | // Return YES for supported orientations 91 | return (interfaceOrientation == UIInterfaceOrientationPortrait); 92 | } 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /SSHCore/SSHCoreAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // SSHCoreAppDelegate.m 3 | // SSHCore 4 | // 5 | // This file is part of SSHCore 6 | // See https://github.com/lhagan/SSHCore for more information 7 | // Copyright (c) 2010-2011 Luke D Hagan 8 | // 9 | 10 | #import "SSHCoreAppDelegate.h" 11 | 12 | #import "SSHCoreViewController.h" 13 | 14 | @implementation SSHCoreAppDelegate 15 | 16 | 17 | @synthesize window=_window; 18 | 19 | @synthesize viewController=_viewController; 20 | 21 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 22 | { 23 | // Override point for customization after application launch. 24 | 25 | self.window.rootViewController = self.viewController; 26 | [self.window makeKeyAndVisible]; 27 | return YES; 28 | } 29 | 30 | - (void)applicationWillResignActive:(UIApplication *)application 31 | { 32 | /* 33 | Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 34 | Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 35 | */ 36 | } 37 | 38 | - (void)applicationDidEnterBackground:(UIApplication *)application 39 | { 40 | /* 41 | Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 42 | If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 43 | */ 44 | } 45 | 46 | - (void)applicationWillEnterForeground:(UIApplication *)application 47 | { 48 | /* 49 | Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 50 | */ 51 | } 52 | 53 | - (void)applicationDidBecomeActive:(UIApplication *)application 54 | { 55 | /* 56 | Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 57 | */ 58 | } 59 | 60 | - (void)applicationWillTerminate:(UIApplication *)application 61 | { 62 | /* 63 | Called when the application is about to terminate. 64 | Save data if appropriate. 65 | See also applicationDidEnterBackground:. 66 | */ 67 | } 68 | 69 | - (void)dealloc 70 | { 71 | [_window release]; 72 | [_viewController release]; 73 | [super dealloc]; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /readme.markdown: -------------------------------------------------------------------------------- 1 | SSHCore Framework 2 | =========== 3 | A Cocoa wrapper for libssh2 4 | 5 | **Note: SSHCore is no longer supported or under active development. You might want to try 6 | [libssh2-for-iOS](https://github.com/x2on/libssh2-for-iOS) instead.** 7 | 8 | SSHCore is a start at wrapping libssh2 into a convenient package for use on iOS. It's currently 9 | just a proof of concept so functionality is limited and error handling is very minimal. The whole thing 10 | is also quite subject to change. The long-term goal of the project is to provide a simple, drop-in 11 | framework that allows iOS applications to interact with SSH servers. 12 | 13 | It's been significantly rewritten 14 | from the first version to exclusively support the iOS Simulator and devices (iPhone, iPad, etc.). The 15 | present implementation is a demo project that can: 16 | 17 | * connect to an SSH server using password or key-based authentication 18 | * run commands on the remote server and get any stdout back as an NSString 19 | 20 | Currently, SSHCore can only connect to a (stock) Mac OS X system using key-based authentication. The OS X SSH 21 | server is configured out of the box to reject password authentication, requiring instead interactive auth. 22 | 23 | To Do: 24 | ------ 25 | 26 | * re-implementation of SCP & SFTP support (removed for version 0.1.0) 27 | * improved authentication support 28 | * actual error handling 29 | * framework architecture 30 | 31 | Usage 32 | ------- 33 | 34 | Here is a simple usage example. Currently, this entire project is an example, so you'll find pretty much the same 35 | thing in `SSHCoreViewController.m`. 36 | 37 | To use, copy SSHCore.m & .h and everything from the Supporting Files/Library group into your project. 38 | Make sure you add `-lz` to Other Compiler Flags in your project's settings as SSHCore's libraries require libz. 39 | 40 | #import "SSHCore.h" 41 | 42 | // create an ssh object 43 | ssh *myssh = [[ssh alloc] init]; 44 | 45 | // get the libssh2 version 46 | [myssh libssh2ver]; 47 | 48 | // log in to server using password auth 49 | [myssh initWithHost: @"192.168.0.100" 50 | port: 22 51 | user: @"user" 52 | key: @"" 53 | keypub: @"" 54 | password: @"password"]; 55 | 56 | // or log in to server using key (leave password blank) 57 | [myssh initWithHost: @"192.168.0.100" 58 | port: 22 59 | user: @"user" 60 | key: @"/path/to/key" 61 | keypub: @"/path/to/key.pub" 62 | password: @""]; 63 | 64 | // execute a command on the remote server 65 | NSString *result = [myssh execCommand: "uptime"]; 66 | NSLog(@"%@", result); 67 | 68 | // close SSH connection & release object 69 | [myssh closeSSH]; 70 | [myssh release]; 71 | 72 | Building Libraries 73 | ------------------ 74 | 75 | The precompiled library binaries (*.a) currently only support armv6 and i386. See `library-build-notes.txt` for steps to build universal binaries of these libraries for all current iOS hardware and the simulator. 76 | 77 | Using on OS X 78 | ------------- 79 | 80 | This framework is targeted at iOS only, but Dan Finneran has written a [libssh2 wrapper for OS X](http://thebsdbox.co.uk/?p=257) based on SSHCore that you might want to check out. 81 | 82 | License 83 | ------- 84 | 85 | Copyright (c) 2010-2011 Luke D Hagan 86 | All rights reserved. 87 | Released under the BSD license. 88 | 89 | Includes a copy of libssh2, an open-source library released 90 | under the BSD licence. libssh2 is copyright the libssh2 team 91 | and respective authors. See [http://www.libssh2.org](http://www.libssh2.org) 92 | for more information. 93 | 94 | Redistribution and use in source and binary forms, 95 | with or without modification, are permitted provided 96 | that the following conditions are met: 97 | 98 | Redistributions of source code must retain the above 99 | copyright notice, this list of conditions and the 100 | following disclaimer. 101 | 102 | Redistributions in binary form must reproduce the above 103 | copyright notice, this list of conditions and the following 104 | disclaimer in the documentation and/or other materials 105 | provided with the distribution. 106 | 107 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 108 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 109 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 110 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 111 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 112 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 113 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 114 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 115 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 116 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 117 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 118 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 119 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 120 | OF SUCH DAMAGE. 121 | -------------------------------------------------------------------------------- /SSHCore/libssh2_publickey.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2004-2006, Sara Golemon 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, 5 | * with or without modification, are permitted provided 6 | * that the following conditions are met: 7 | * 8 | * Redistributions of source code must retain the above 9 | * copyright notice, this list of conditions and the 10 | * following disclaimer. 11 | * 12 | * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following 14 | * disclaimer in the documentation and/or other materials 15 | * provided with the distribution. 16 | * 17 | * Neither the name of the copyright holder nor the names 18 | * of any other contributors may be used to endorse or 19 | * promote products derived from this software without 20 | * specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 24 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 27 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 32 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 34 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 35 | * OF SUCH DAMAGE. 36 | */ 37 | 38 | /* Note: This include file is only needed for using the 39 | * publickey SUBSYSTEM which is not the same as publickey 40 | * authentication. For authentication you only need libssh2.h 41 | * 42 | * For more information on the publickey subsystem, 43 | * refer to IETF draft: secsh-publickey 44 | */ 45 | 46 | #ifndef LIBSSH2_PUBLICKEY_H 47 | #define LIBSSH2_PUBLICKEY_H 1 48 | 49 | #include "libssh2.h" 50 | 51 | typedef struct _LIBSSH2_PUBLICKEY LIBSSH2_PUBLICKEY; 52 | 53 | typedef struct _libssh2_publickey_attribute { 54 | const char *name; 55 | unsigned long name_len; 56 | const char *value; 57 | unsigned long value_len; 58 | char mandatory; 59 | } libssh2_publickey_attribute; 60 | 61 | typedef struct _libssh2_publickey_list { 62 | unsigned char *packet; /* For freeing */ 63 | 64 | const unsigned char *name; 65 | unsigned long name_len; 66 | const unsigned char *blob; 67 | unsigned long blob_len; 68 | unsigned long num_attrs; 69 | libssh2_publickey_attribute *attrs; /* free me */ 70 | } libssh2_publickey_list; 71 | 72 | /* Generally use the first macro here, but if both name and value are string literals, you can use _fast() to take advantage of preprocessing */ 73 | #define libssh2_publickey_attribute(name, value, mandatory) \ 74 | { (name), strlen(name), (value), strlen(value), (mandatory) }, 75 | #define libssh2_publickey_attribute_fast(name, value, mandatory) \ 76 | { (name), sizeof(name) - 1, (value), sizeof(value) - 1, (mandatory) }, 77 | 78 | #ifdef __cplusplus 79 | extern "C" { 80 | #endif 81 | 82 | /* Publickey Subsystem */ 83 | LIBSSH2_API LIBSSH2_PUBLICKEY *libssh2_publickey_init(LIBSSH2_SESSION *session); 84 | 85 | LIBSSH2_API int libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY *pkey, 86 | const unsigned char *name, 87 | unsigned long name_len, 88 | const unsigned char *blob, 89 | unsigned long blob_len, char overwrite, 90 | unsigned long num_attrs, 91 | const libssh2_publickey_attribute attrs[]); 92 | #define libssh2_publickey_add(pkey, name, blob, blob_len, overwrite, \ 93 | num_attrs, attrs) \ 94 | libssh2_publickey_add_ex((pkey), (name), strlen(name), (blob), (blob_len), \ 95 | (overwrite), (num_attrs), (attrs)) 96 | 97 | LIBSSH2_API int libssh2_publickey_remove_ex(LIBSSH2_PUBLICKEY *pkey, 98 | const unsigned char *name, 99 | unsigned long name_len, 100 | const unsigned char *blob, 101 | unsigned long blob_len); 102 | #define libssh2_publickey_remove(pkey, name, blob, blob_len) \ 103 | libssh2_publickey_remove_ex((pkey), (name), strlen(name), (blob), (blob_len)) 104 | 105 | LIBSSH2_API int 106 | libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY *pkey, 107 | unsigned long *num_keys, 108 | libssh2_publickey_list **pkey_list); 109 | LIBSSH2_API void libssh2_publickey_list_free(LIBSSH2_PUBLICKEY *pkey, 110 | libssh2_publickey_list *pkey_list); 111 | 112 | LIBSSH2_API int libssh2_publickey_shutdown(LIBSSH2_PUBLICKEY *pkey); 113 | 114 | #ifdef __cplusplus 115 | } /* extern "C" */ 116 | #endif 117 | 118 | #endif /* ifndef: LIBSSH2_PUBLICKEY_H */ 119 | -------------------------------------------------------------------------------- /library-build-notes.txt: -------------------------------------------------------------------------------- 1 | # 2 | # set up working directory 3 | # 4 | export PREFIX= 5 | cd $PREFIX 6 | mkdir armv6 armv7 armv9 i386 universal 7 | 8 | # 9 | # download: 10 | # 11 | # gnupgp, libpgp-error, libgcrypt: http://www.gnupg.org/download/index.en.html 12 | # libssh2: http://www.libssh2.org/ 13 | # unpack each into working directory 14 | 15 | # 16 | # configure and build for armv6 17 | # 18 | export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer 19 | export SDKROOT=$DEVROOT/SDKs/iPhoneOS4.2.sdk 20 | export CC=$DEVROOT/usr/bin/gcc 21 | export LD=$DEVROOT/usr/bin/ld 22 | export CPP=$DEVROOT/usr/bin/cpp 23 | export CXX=$DEVROOT/usr/bin/g++ 24 | export AR=$DEVROOT/usr/bin/ar 25 | export AS=$DEVROOT/usr/bin/as 26 | export NM=$DEVROOT/usr/bin/nm 27 | export CXXCPP=$DEVROOT/usr/bin/cpp 28 | export RANLIB=$DEVROOT/usr/bin/ranlib 29 | export LDFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -L$PREFIX/armv6/lib" 30 | export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I$PREFIX/armv6/include" 31 | export CXXFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I$PREFIX/armv6" 32 | 33 | pushd gnupgp-1.4.11 34 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv6 35 | make && make install 36 | popd 37 | 38 | pushd libgpg-error-1.10 39 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv6 --enable-shared=no 40 | make && make install 41 | popd 42 | 43 | pushd libgcrypt-1.4.6 44 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv6 --enable-shared=no 45 | --with-gpg-error-prefix=$PREFIX/armv6 46 | make && make install 47 | 48 | pushd libssh2-1.2.7 49 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv6 --with-libgcrypt-prefix=$PREFIX/armv6 50 | make && make install 51 | popd 52 | 53 | # 54 | # configure and build for armv7 55 | # 56 | export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer 57 | export SDKROOT=$DEVROOT/SDKs/iPhoneOS4.2.sdk 58 | export CC=$DEVROOT/usr/bin/gcc 59 | export LD=$DEVROOT/usr/bin/ld 60 | export CPP=$DEVROOT/usr/bin/cpp 61 | export CXX=$DEVROOT/usr/bin/g++ 62 | export AR=$DEVROOT/usr/bin/ar 63 | export AS=$DEVROOT/usr/bin/as 64 | export NM=$DEVROOT/usr/bin/nm 65 | export CXXCPP=$DEVROOT/usr/bin/cpp 66 | export RANLIB=$DEVROOT/usr/bin/ranlib 67 | export LDFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -L$PREFIX/armv7/lib" 68 | export CFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -I$PREFIX/armv7/include" 69 | export CXXFLAGS="-arch armv7 -pipe -no-cpp-precomp -isysroot $SDKROOT -I$PREFIX/armv7" 70 | 71 | pushd gnupgp-1.4.11 72 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv7 73 | make && make install 74 | popd 75 | 76 | pushd libgpg-error-1.10 77 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv7 --enable-shared=no 78 | make && make install 79 | popd 80 | 81 | pushd libgcrypt-1.4.6 82 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv7 --enable-shared=no 83 | --with-gpg-error-prefix=$PREFIX/armv7 84 | make && make install 85 | 86 | pushd libssh2-1.2.7 87 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv7 --with-libgcrypt-prefix=$PREFIX/armv7 88 | make && make install 89 | popd 90 | 91 | # 92 | # configure and build for armv9 93 | # 94 | export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer 95 | export SDKROOT=$DEVROOT/SDKs/iPhoneOS4.2.sdk 96 | export CC=$DEVROOT/usr/bin/gcc 97 | export LD=$DEVROOT/usr/bin/ld 98 | export CPP=$DEVROOT/usr/bin/cpp 99 | export CXX=$DEVROOT/usr/bin/g++ 100 | export AR=$DEVROOT/usr/bin/ar 101 | export AS=$DEVROOT/usr/bin/as 102 | export NM=$DEVROOT/usr/bin/nm 103 | export CXXCPP=$DEVROOT/usr/bin/cpp 104 | export RANLIB=$DEVROOT/usr/bin/ranlib 105 | export LDFLAGS="-arch armv9 -pipe -no-cpp-precomp -isysroot $SDKROOT -L$PREFIX/armv9/lib" 106 | export CFLAGS="-arch armv9 -pipe -no-cpp-precomp -isysroot $SDKROOT -I$PREFIX/armv9/include" 107 | export CXXFLAGS="-arch armv9 -pipe -no-cpp-precomp -isysroot $SDKROOT -I$PREFIX/armv9" 108 | 109 | pushd gnupgp-1.4.11 110 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv9 111 | make && make install 112 | popd 113 | 114 | pushd libgpg-error-1.10 115 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv9 --enable-shared=no 116 | make && make install 117 | popd 118 | 119 | pushd libgcrypt-1.4.6 120 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv9 --enable-shared=no 121 | --with-gpg-error-prefix=$PREFIX/armv9 122 | make && make install 123 | 124 | pushd libssh2-1.2.7 125 | ./configure --host=arm-apple-darwin10 --prefix=$PREFIX/armv9 --with-libgcrypt-prefix=$PREFIX/armv9 126 | make && make install 127 | popd 128 | 129 | # 130 | # configure and build for simulator (i386) 131 | # 132 | export DEVROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer 133 | export INSTALLPREFIX=$PREFIX/i386 134 | export SDKROOT=$DEVROOT/SDKs/iPhoneSimulator3.2.sdk 135 | export CC=$DEVROOT/usr/bin/gcc-4.2 136 | export LD=$DEVROOT/usr/bin/ld 137 | export CPP=$DEVROOT/usr/bin/cpp-4.2 138 | export CXX=$DEVROOT/usr/bin/g++-4.2 139 | export AR=$DEVROOT/usr/bin/ar 140 | export AS=$DEVROOT/usr/bin/as 141 | export NM=$DEVROOT/usr/bin/nm 142 | export CXXCPP=$DEVROOT/usr/bin/cpp-4.2 143 | export RANLIB=$DEVROOT/usr/bin/ranlib 144 | export LDFLAGS="-arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT -L$INSTALLPREFIX/lib" 145 | export CFLAGS="-arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT -I$INSTALLPREFIX/include" 146 | export CXXFLAGS="-arch i386 -pipe -no-cpp-precomp -isysroot $SDKROOT -I$INSTALLPREFIX/include/" 147 | export CFLAGS=-m32 148 | export CPPFLAGS=-m32 149 | 150 | pushd gnupg-1.4.11 151 | make clean 152 | ./configure --host=i386-apple-darwin --prefix=$INSTALLPREFIX 153 | make && make install 154 | popd 155 | 156 | pushd libgpg-error-1.10 157 | make clean 158 | ./configure --host=i386-apple-darwin --prefix=$INSTALLPREFIX --enable-shared=no 159 | make && make install 160 | popd 161 | 162 | pushd libgcrypt-1.4.6 163 | make clean 164 | ./configure --host=i386-apple-darwin --prefix=$INSTALLPREFIX --enable-shared=no --with-gpg-error-prefix=$INSTALLPREFIX --disable-asm 165 | make && make install 166 | popd 167 | 168 | pushd libssh2-1.2.7 169 | make clean 170 | ./configure --host=i386-apple-darwin --prefix=$INSTALLPREFIX --with-libgcrypt-prefix=$INSTALLPREFIX/../libraries/libgcrypt-1.4.6 171 | make && make install 172 | popd 173 | 174 | # 175 | # make universal binary 176 | # 177 | lipo -create i386/lib/libgcrypt.a armv6/lib/libgcrypt.a armv7/lib/libgcrypt.a-output armv9/lib/libgcrypt.a universal/libgcrypt.a 178 | lipo -create i386/lib/libgpg-error.a armv6/lib/libgpg-error.a armv7/lib/libgpg-error.a armv9/lib/libgpg-error.a -output universal/libgpg-error.a 179 | lipo -create i386/lib/libssh2.a armv6/lib/libssh2.a armv7/lib/libssh2.a armv9/lib/libssh2.a -output universal/libssh2.a -------------------------------------------------------------------------------- /SSHCore/libssh2_config.h: -------------------------------------------------------------------------------- 1 | /* example/libssh2_config.h. Generated from libssh2_config.h.in by configure. */ 2 | /* src/libssh2_config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define if building universal (internal helper macro) */ 5 | /* #undef AC_APPLE_UNIVERSAL_BUILD */ 6 | 7 | /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP 8 | systems. This function is required for `alloca.c' support on those systems. 9 | */ 10 | /* #undef CRAY_STACKSEG_END */ 11 | 12 | /* Define to 1 if using `alloca.c'. */ 13 | /* #undef C_ALLOCA */ 14 | 15 | /* Define to 1 if you have `alloca', as a function or macro. */ 16 | #define HAVE_ALLOCA 1 17 | 18 | /* Define to 1 if you have and it should be used (not on Ultrix). 19 | */ 20 | #define HAVE_ALLOCA_H 1 21 | 22 | /* Define to 1 if you have the header file. */ 23 | #define HAVE_ARPA_INET_H 1 24 | 25 | /* disabled non-blocking sockets */ 26 | /* #undef HAVE_DISABLED_NONBLOCKING */ 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_DLFCN_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_ERRNO_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_FCNTL_H 1 36 | 37 | /* use FIONBIO for non-blocking sockets */ 38 | /* #undef HAVE_FIONBIO */ 39 | 40 | /* Define to 1 if you have the `gettimeofday' function. */ 41 | #define HAVE_GETTIMEOFDAY 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_INTTYPES_H 1 45 | 46 | /* use ioctlsocket() for non-blocking sockets */ 47 | /* #undef HAVE_IOCTLSOCKET */ 48 | 49 | /* use Ioctlsocket() for non-blocking sockets */ 50 | /* #undef HAVE_IOCTLSOCKET_CASE */ 51 | 52 | /* Define if you have the gcrypt library. */ 53 | /* #undef HAVE_LIBGCRYPT */ 54 | 55 | /* Define if you have the ssl library. */ 56 | #define HAVE_LIBSSL 1 57 | 58 | /* Define if you have the z library. */ 59 | #define HAVE_LIBZ 1 60 | 61 | /* Define to 1 if the compiler supports the 'long long' data type. */ 62 | #define HAVE_LONGLONG 1 63 | 64 | /* Define to 1 if you have the header file. */ 65 | #define HAVE_MEMORY_H 1 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #define HAVE_NETINET_IN_H 1 69 | 70 | /* use O_NONBLOCK for non-blocking sockets */ 71 | #define HAVE_O_NONBLOCK 1 72 | 73 | /* Define to 1 if you have the `poll' function. */ 74 | #define HAVE_POLL 1 75 | 76 | /* Define to 1 if you have the select function. */ 77 | #define HAVE_SELECT 1 78 | 79 | /* use SO_NONBLOCK for non-blocking sockets */ 80 | /* #undef HAVE_SO_NONBLOCK */ 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #define HAVE_STDINT_H 1 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #define HAVE_STDIO_H 1 87 | 88 | /* Define to 1 if you have the header file. */ 89 | #define HAVE_STDLIB_H 1 90 | 91 | /* Define to 1 if you have the header file. */ 92 | #define HAVE_STRINGS_H 1 93 | 94 | /* Define to 1 if you have the header file. */ 95 | #define HAVE_STRING_H 1 96 | 97 | /* Define to 1 if you have the `strtoll' function. */ 98 | #define HAVE_STRTOLL 1 99 | 100 | /* Define to 1 if you have the header file. */ 101 | #define HAVE_SYS_IOCTL_H 1 102 | 103 | /* Define to 1 if you have the header file. */ 104 | #define HAVE_SYS_SELECT_H 1 105 | 106 | /* Define to 1 if you have the header file. */ 107 | #define HAVE_SYS_SOCKET_H 1 108 | 109 | /* Define to 1 if you have the header file. */ 110 | #define HAVE_SYS_STAT_H 1 111 | 112 | /* Define to 1 if you have the header file. */ 113 | #define HAVE_SYS_TIME_H 1 114 | 115 | /* Define to 1 if you have the header file. */ 116 | #define HAVE_SYS_TYPES_H 1 117 | 118 | /* Define to 1 if you have the header file. */ 119 | #define HAVE_SYS_UIO_H 1 120 | 121 | /* Define to 1 if you have the header file. */ 122 | #define HAVE_SYS_UN_H 1 123 | 124 | /* Define to 1 if you have the header file. */ 125 | #define HAVE_UNISTD_H 1 126 | 127 | /* Define to 1 if you have the header file. */ 128 | /* #undef HAVE_WINDOWS_H */ 129 | 130 | /* Define to 1 if you have the header file. */ 131 | /* #undef HAVE_WINSOCK2_H */ 132 | 133 | /* Define to 1 if you have the header file. */ 134 | /* #undef HAVE_WS2TCPIP_H */ 135 | 136 | /* to make a symbol visible */ 137 | /* #undef LIBSSH2_API */ 138 | 139 | /* Enable "none" cipher -- NOT RECOMMENDED */ 140 | /* #undef LIBSSH2_CRYPT_NONE */ 141 | 142 | /* Enable newer diffie-hellman-group-exchange-sha1 syntax */ 143 | #define LIBSSH2_DH_GEX_NEW 1 144 | 145 | /* Compile in zlib support */ 146 | #define LIBSSH2_HAVE_ZLIB 1 147 | 148 | /* Use libgcrypt */ 149 | /* #undef LIBSSH2_LIBGCRYPT */ 150 | 151 | /* Enable "none" MAC -- NOT RECOMMENDED */ 152 | /* #undef LIBSSH2_MAC_NONE */ 153 | 154 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 155 | */ 156 | #define LT_OBJDIR ".libs/" 157 | 158 | /* Define to 1 if _REENTRANT preprocessor symbol must be defined. */ 159 | /* #undef NEED_REENTRANT */ 160 | 161 | /* Name of package */ 162 | #define PACKAGE "libssh2" 163 | 164 | /* Define to the address where bug reports for this package should be sent. */ 165 | #define PACKAGE_BUGREPORT "libssh2-devel@cool.haxx.se" 166 | 167 | /* Define to the full name of this package. */ 168 | #define PACKAGE_NAME "libssh2" 169 | 170 | /* Define to the full name and version of this package. */ 171 | #define PACKAGE_STRING "libssh2 -" 172 | 173 | /* Define to the one symbol short name of this package. */ 174 | #define PACKAGE_TARNAME "libssh2" 175 | 176 | /* Define to the home page for this package. */ 177 | #define PACKAGE_URL "" 178 | 179 | /* Define to the version of this package. */ 180 | #define PACKAGE_VERSION "-" 181 | 182 | /* If using the C implementation of alloca, define if you know the 183 | direction of stack growth for your system; otherwise it will be 184 | automatically deduced at runtime. 185 | STACK_DIRECTION > 0 => grows toward higher addresses 186 | STACK_DIRECTION < 0 => grows toward lower addresses 187 | STACK_DIRECTION = 0 => direction of growth unknown */ 188 | /* #undef STACK_DIRECTION */ 189 | 190 | /* Define to 1 if you have the ANSI C header files. */ 191 | #define STDC_HEADERS 1 192 | 193 | /* Version number of package */ 194 | #define VERSION "1.2.4" 195 | 196 | /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most 197 | significant byte first (like Motorola and SPARC, unlike Intel). */ 198 | #if defined AC_APPLE_UNIVERSAL_BUILD 199 | # if defined __BIG_ENDIAN__ 200 | # define WORDS_BIGENDIAN 1 201 | # endif 202 | #else 203 | # ifndef WORDS_BIGENDIAN 204 | /* # undef WORDS_BIGENDIAN */ 205 | # endif 206 | #endif 207 | 208 | /* Number of bits in a file offset, on hosts where this is settable. */ 209 | /* #undef _FILE_OFFSET_BITS */ 210 | 211 | /* Define for large files, on AIX-style hosts. */ 212 | /* #undef _LARGE_FILES */ 213 | 214 | /* Define to empty if `const' does not conform to ANSI C. */ 215 | /* #undef const */ 216 | 217 | /* Define to `__inline__' or `__inline' if that's what the C compiler 218 | calls it, or to nothing if 'inline' is not supported under any name. */ 219 | #ifndef __cplusplus 220 | /* #undef inline */ 221 | #endif 222 | -------------------------------------------------------------------------------- /SSHCore/en.lproj/SSHCoreViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1056 5 | 10J869 6 | 1306 7 | 1038.35 8 | 461.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 301 12 | 13 | 14 | YES 15 | IBProxyObject 16 | IBUITextView 17 | IBUIView 18 | 19 | 20 | YES 21 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 22 | 23 | 24 | YES 25 | 26 | YES 27 | 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | 42 | 274 43 | 44 | YES 45 | 46 | 47 | 292 48 | {320, 460} 49 | 50 | 51 | 52 | 1 53 | MSAxIDEAA 54 | 55 | YES 56 | YES 57 | IBCocoaTouchFramework 58 | NO 59 | Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. 60 | 61 | 2 62 | IBCocoaTouchFramework 63 | 64 | 65 | 66 | {{0, 20}, {320, 460}} 67 | 68 | 69 | 70 | 71 | 3 72 | MC43NQA 73 | 74 | 2 75 | 76 | 77 | NO 78 | 79 | IBCocoaTouchFramework 80 | 81 | 82 | 83 | 84 | YES 85 | 86 | 87 | view 88 | 89 | 90 | 91 | 7 92 | 93 | 94 | 95 | viewText 96 | 97 | 98 | 99 | 10 100 | 101 | 102 | 103 | 104 | YES 105 | 106 | 0 107 | 108 | 109 | 110 | 111 | 112 | -1 113 | 114 | 115 | File's Owner 116 | 117 | 118 | -2 119 | 120 | 121 | 122 | 123 | 6 124 | 125 | 126 | YES 127 | 128 | 129 | 130 | 131 | 132 | 9 133 | 134 | 135 | 136 | 137 | 138 | 139 | YES 140 | 141 | YES 142 | -1.CustomClassName 143 | -2.CustomClassName 144 | 6.IBEditorWindowLastContentRect 145 | 6.IBPluginDependency 146 | 9.IBPluginDependency 147 | 9.IBViewBoundsToFrameTransform 148 | 149 | 150 | YES 151 | SSHCoreViewController 152 | UIResponder 153 | {{239, 654}, {320, 480}} 154 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 155 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 156 | 157 | P4AAAL+AAABBoAAAwy8AAA 158 | 159 | 160 | 161 | 162 | YES 163 | 164 | 165 | 166 | 167 | 168 | YES 169 | 170 | 171 | 172 | 173 | 10 174 | 175 | 176 | 177 | YES 178 | 179 | SSHCoreViewController 180 | UIViewController 181 | 182 | viewText 183 | UITextView 184 | 185 | 186 | viewText 187 | 188 | viewText 189 | UITextView 190 | 191 | 192 | 193 | IBProjectSource 194 | ./Classes/SSHCoreViewController.h 195 | 196 | 197 | 198 | 199 | 0 200 | IBCocoaTouchFramework 201 | 202 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 203 | 204 | 205 | YES 206 | 3 207 | 301 208 | 209 | 210 | -------------------------------------------------------------------------------- /SSHCore/SSHCore.m: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2004-2007 Sara Golemon 2 | * Copyright (c) 2006-2007 The Written Word, Inc. 3 | * Copyright (c) 2009 Daniel Stenberg 4 | * Copyright (C) 2008, 2009 Simon Josefsson 5 | * Copyright (c) 2010-2011 Luke D Hagan 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, 9 | * with or without modification, are permitted provided 10 | * that the following conditions are met: 11 | * 12 | * Redistributions of source code must retain the above 13 | * copyright notice, this list of conditions and the 14 | * following disclaimer. 15 | * 16 | * Redistributions in binary form must reproduce the above 17 | * copyright notice, this list of conditions and the following 18 | * disclaimer in the documentation and/or other materials 19 | * provided with the distribution. 20 | * 21 | * Neither the name of the copyright holder nor the names 22 | * of any other contributors may be used to endorse or 23 | * promote products derived from this software without 24 | * specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 27 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 28 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 31 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 33 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 36 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 37 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 38 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 39 | * OF SUCH DAMAGE. 40 | */ 41 | 42 | #import "SSHCore.h" 43 | 44 | #include "libssh2_config.h" 45 | #include "libssh2.h" 46 | 47 | #ifdef HAVE_WINSOCK2_H 48 | # include 49 | #endif 50 | #ifdef HAVE_SYS_SOCKET_H 51 | # include 52 | #endif 53 | #ifdef HAVE_NETINET_IN_H 54 | # include 55 | #endif 56 | #ifdef HAVE_SYS_SELECT_H 57 | # include 58 | #endif 59 | # ifdef HAVE_UNISTD_H 60 | #include 61 | #endif 62 | #ifdef HAVE_ARPA_INET_H 63 | # include 64 | #endif 65 | 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | 74 | unsigned long hostaddr; 75 | int sock; 76 | struct sockaddr_in soin; 77 | const char *fingerprint; 78 | LIBSSH2_SESSION *session; 79 | LIBSSH2_CHANNEL *channel; 80 | int rc; 81 | int exitcode; 82 | int bytecount = 0; 83 | size_t len; 84 | LIBSSH2_KNOWNHOSTS *nh; 85 | int type; 86 | 87 | // from libssh2 example - ssh2_exec.c 88 | static int waitsocket(int socket_fd, LIBSSH2_SESSION *session) 89 | { 90 | struct timeval timeout; 91 | int rc; 92 | fd_set fd; 93 | fd_set *writefd = NULL; 94 | fd_set *readfd = NULL; 95 | int dir; 96 | 97 | timeout.tv_sec = 10; 98 | timeout.tv_usec = 0; 99 | 100 | FD_ZERO(&fd); 101 | 102 | FD_SET(socket_fd, &fd); 103 | 104 | /* now make sure we wait in the correct direction */ 105 | dir = libssh2_session_block_directions(session); 106 | 107 | if(dir & LIBSSH2_SESSION_BLOCK_INBOUND) 108 | readfd = &fd; 109 | 110 | if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND) 111 | writefd = &fd; 112 | 113 | rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout); 114 | 115 | return rc; 116 | } 117 | 118 | /* diff in ms */ 119 | static long tvdiff(struct timeval newer, struct timeval older) 120 | { 121 | return (newer.tv_sec-older.tv_sec)*1000+ 122 | (newer.tv_usec-older.tv_usec)/1000; 123 | } 124 | 125 | @implementation ssh 126 | 127 | -(int) initWithHost:(NSString*)host port:(int) p user:(NSString*)user key:(NSString*)k keypub:(NSString*)kpub password:(NSString*)pass { 128 | hostname = [host UTF8String]; 129 | port = p; 130 | username = [user UTF8String]; 131 | key = [k UTF8String]; 132 | keypub = [kpub UTF8String]; 133 | password = [pass UTF8String]; 134 | 135 | #ifdef WIN32 136 | WSADATA wsadata; 137 | WSAStartup(MAKEWORD(2,0), &wsadata); 138 | #endif 139 | 140 | hostaddr = inet_addr(hostname); 141 | 142 | /* Ultra basic "connect to port 22 on localhost" 143 | * Your code is responsible for creating the socket establishing the 144 | * connection 145 | */ 146 | sock = socket(AF_INET, SOCK_STREAM, 0); 147 | 148 | soin.sin_family = AF_INET; 149 | soin.sin_port = htons(port); 150 | soin.sin_addr.s_addr = hostaddr; 151 | if (connect(sock, (struct sockaddr*)(&soin), 152 | sizeof(struct sockaddr_in)) != 0) { 153 | NSLog(@"Failed to connect!"); 154 | return -1; 155 | } 156 | 157 | /* Create a session instance */ 158 | session = libssh2_session_init(); 159 | if (!session) 160 | return -1; 161 | 162 | /* tell libssh2 we want it all done non-blocking */ 163 | libssh2_session_set_blocking(session, 0); 164 | 165 | /* ... start it up. This will trade welcome banners, exchange keys, 166 | * and setup crypto, compression, and MAC layers 167 | */ 168 | while ((rc = libssh2_session_startup(session, sock)) == 169 | LIBSSH2_ERROR_EAGAIN); 170 | if (rc) { 171 | NSLog(@"Failure establishing SSH session: %d", rc); 172 | return -1; 173 | } 174 | 175 | nh = libssh2_knownhost_init(session); 176 | if(!nh) { 177 | /* eeek, do cleanup here */ 178 | return 2; 179 | } 180 | 181 | /* read all hosts from here */ 182 | libssh2_knownhost_readfile(nh, "known_hosts", 183 | LIBSSH2_KNOWNHOST_FILE_OPENSSH); 184 | 185 | /* store all known hosts to here */ 186 | libssh2_knownhost_writefile(nh, "dumpfile", 187 | LIBSSH2_KNOWNHOST_FILE_OPENSSH); 188 | 189 | fingerprint = libssh2_session_hostkey(session, &len, &type); 190 | if(fingerprint) { 191 | struct libssh2_knownhost *host; 192 | int check = libssh2_knownhost_check(nh, (char *)hostname, 193 | (char *)fingerprint, len, 194 | LIBSSH2_KNOWNHOST_TYPE_PLAIN| 195 | LIBSSH2_KNOWNHOST_KEYENC_RAW, 196 | &host); 197 | 198 | NSLog(@"Host check: %d, key: %s", check, 199 | (check <= LIBSSH2_KNOWNHOST_CHECK_MISMATCH)? 200 | host->key:""); 201 | 202 | /***** 203 | * At this point, we could verify that 'check' tells us the key is 204 | * fine or bail out. 205 | *****/ 206 | } 207 | else { 208 | /* eeek, do cleanup here */ 209 | return 3; 210 | } 211 | libssh2_knownhost_free(nh); 212 | 213 | if ( strlen(password) != 0 ) { 214 | if ( 1 ) { 215 | /* We could authenticate via password */ 216 | while ((rc = libssh2_userauth_password(session, username, password)) == 217 | LIBSSH2_ERROR_EAGAIN); 218 | if (rc) { 219 | NSLog(@"Authentication by password failed."); 220 | return 1; 221 | } 222 | } 223 | else { 224 | /* Or by public key */ 225 | while ((rc = libssh2_userauth_publickey_fromfile(session, username, keypub, key, password)) == LIBSSH2_ERROR_EAGAIN); 226 | if (rc) { 227 | NSLog(@"Authentication by public key failed"); 228 | return 1; 229 | } 230 | } 231 | 232 | #if 0 233 | libssh2_trace(session, ~0 ); 234 | #endif 235 | 236 | } 237 | return 0; 238 | } 239 | 240 | // from libssh2 example - ssh2_exec.c 241 | -(NSString*) execCommand: (NSString *)commandline { 242 | NSString *result; 243 | const char * cmd = [commandline UTF8String]; 244 | 245 | /* Exec non-blocking on the remote host */ 246 | while( (channel = libssh2_channel_open_session(session)) == NULL && 247 | libssh2_session_last_error(session,NULL,NULL,0) == 248 | LIBSSH2_ERROR_EAGAIN ) 249 | { 250 | waitsocket(sock, session); 251 | } 252 | if( channel == NULL ) 253 | { 254 | NSLog(@"Error\n"); 255 | exit( 1 ); 256 | } 257 | while( (rc = libssh2_channel_exec(channel, cmd)) == 258 | LIBSSH2_ERROR_EAGAIN ) 259 | { 260 | waitsocket(sock, session); 261 | } 262 | if( rc != 0 ) 263 | { 264 | NSLog(@"Error\n"); 265 | exit( 1 ); 266 | } 267 | for( ;; ) 268 | { 269 | /* loop until we block */ 270 | int rc1; 271 | do 272 | { 273 | char buffer[0x4000]; 274 | rc1 = libssh2_channel_read( channel, buffer, sizeof(buffer) ); 275 | if( rc1 > 0 ) 276 | { 277 | result = [NSString stringWithCString:buffer encoding: 4]; 278 | 279 | //int i; 280 | bytecount += rc1; 281 | /*fprintf(stderr, "We read:\n"); 282 | for( i=0; i < rc1; ++i ) 283 | fputc( buffer[i], stderr); 284 | fprintf(stderr, "\n");*/ 285 | } 286 | else { 287 | NSLog(@"libssh2_channel_read returned %d", rc1); 288 | } 289 | } 290 | while( rc1 > 0 ); 291 | 292 | /* this is due to blocking that would occur otherwise so we loop on 293 | this condition */ 294 | if( rc1 == LIBSSH2_ERROR_EAGAIN ) 295 | { 296 | waitsocket(sock, session); 297 | } 298 | else 299 | break; 300 | } 301 | exitcode = 127; 302 | while( (rc = libssh2_channel_close(channel)) == LIBSSH2_ERROR_EAGAIN ) 303 | waitsocket(sock, session); 304 | 305 | if( rc == 0 ) 306 | { 307 | exitcode = libssh2_channel_get_exit_status( channel ); 308 | } 309 | NSLog(@"\nEXIT: %d bytecount: %d", exitcode, bytecount); 310 | 311 | libssh2_channel_free(channel); 312 | channel = NULL; 313 | 314 | return result; 315 | 316 | } 317 | 318 | -(int) closeSSH { 319 | libssh2_session_disconnect(session, 320 | "Normal Shutdown, Thank you for playing"); 321 | libssh2_session_free(session); 322 | 323 | #ifdef WIN32 324 | closesocket(sock); 325 | #else 326 | close(sock); 327 | #endif 328 | NSLog(@"all done\n"); 329 | 330 | return 0; 331 | } 332 | 333 | -(void) libssh2ver { 334 | NSString *version = [NSString stringWithCString:libssh2_version(0) encoding: 4]; 335 | NSLog(@"We are using libssh2 version: %@", version); 336 | } 337 | 338 | @end 339 | -------------------------------------------------------------------------------- /SSHCore/libssh2_sftp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2004-2008, Sara Golemon 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, 5 | * with or without modification, are permitted provided 6 | * that the following conditions are met: 7 | * 8 | * Redistributions of source code must retain the above 9 | * copyright notice, this list of conditions and the 10 | * following disclaimer. 11 | * 12 | * Redistributions in binary form must reproduce the above 13 | * copyright notice, this list of conditions and the following 14 | * disclaimer in the documentation and/or other materials 15 | * provided with the distribution. 16 | * 17 | * Neither the name of the copyright holder nor the names 18 | * of any other contributors may be used to endorse or 19 | * promote products derived from this software without 20 | * specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 24 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 27 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 29 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 32 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 33 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 34 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 35 | * OF SUCH DAMAGE. 36 | */ 37 | 38 | #ifndef LIBSSH2_SFTP_H 39 | #define LIBSSH2_SFTP_H 1 40 | 41 | #include "libssh2.h" 42 | 43 | #ifndef WIN32 44 | #include 45 | #endif 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | /* Note: Version 6 was documented at the time of writing 52 | * However it was marked as "DO NOT IMPLEMENT" due to pending changes 53 | * 54 | * Let's start with Version 3 (The version found in OpenSSH) and go from there 55 | */ 56 | #define LIBSSH2_SFTP_VERSION 3 57 | #define LIBSSH2_SFTP_PACKET_MAXLEN 40000 58 | 59 | typedef struct _LIBSSH2_SFTP LIBSSH2_SFTP; 60 | typedef struct _LIBSSH2_SFTP_HANDLE LIBSSH2_SFTP_HANDLE; 61 | typedef struct _LIBSSH2_SFTP_ATTRIBUTES LIBSSH2_SFTP_ATTRIBUTES; 62 | typedef struct _LIBSSH2_SFTP_STATVFS LIBSSH2_SFTP_STATVFS; 63 | 64 | /* Flags for open_ex() */ 65 | #define LIBSSH2_SFTP_OPENFILE 0 66 | #define LIBSSH2_SFTP_OPENDIR 1 67 | 68 | /* Flags for rename_ex() */ 69 | #define LIBSSH2_SFTP_RENAME_OVERWRITE 0x00000001 70 | #define LIBSSH2_SFTP_RENAME_ATOMIC 0x00000002 71 | #define LIBSSH2_SFTP_RENAME_NATIVE 0x00000004 72 | 73 | /* Flags for stat_ex() */ 74 | #define LIBSSH2_SFTP_STAT 0 75 | #define LIBSSH2_SFTP_LSTAT 1 76 | #define LIBSSH2_SFTP_SETSTAT 2 77 | 78 | /* Flags for symlink_ex() */ 79 | #define LIBSSH2_SFTP_SYMLINK 0 80 | #define LIBSSH2_SFTP_READLINK 1 81 | #define LIBSSH2_SFTP_REALPATH 2 82 | 83 | /* SFTP attribute flag bits */ 84 | #define LIBSSH2_SFTP_ATTR_SIZE 0x00000001 85 | #define LIBSSH2_SFTP_ATTR_UIDGID 0x00000002 86 | #define LIBSSH2_SFTP_ATTR_PERMISSIONS 0x00000004 87 | #define LIBSSH2_SFTP_ATTR_ACMODTIME 0x00000008 88 | #define LIBSSH2_SFTP_ATTR_EXTENDED 0x80000000 89 | 90 | /* SFTP statvfs flag bits */ 91 | #define LIBSSH2_SFTP_ST_RDONLY 0x00000001 92 | #define LIBSSH2_SFTP_ST_NOSUID 0x00000002 93 | 94 | struct _LIBSSH2_SFTP_ATTRIBUTES { 95 | /* If flags & ATTR_* bit is set, then the value in this struct will be 96 | * meaningful Otherwise it should be ignored 97 | */ 98 | unsigned long flags; 99 | 100 | libssh2_uint64_t filesize; 101 | unsigned long uid, gid; 102 | unsigned long permissions; 103 | unsigned long atime, mtime; 104 | }; 105 | 106 | struct _LIBSSH2_SFTP_STATVFS { 107 | libssh2_uint64_t f_bsize; /* file system block size */ 108 | libssh2_uint64_t f_frsize; /* fragment size */ 109 | libssh2_uint64_t f_blocks; /* size of fs in f_frsize units */ 110 | libssh2_uint64_t f_bfree; /* # free blocks */ 111 | libssh2_uint64_t f_bavail; /* # free blocks for non-root */ 112 | libssh2_uint64_t f_files; /* # inodes */ 113 | libssh2_uint64_t f_ffree; /* # free inodes */ 114 | libssh2_uint64_t f_favail; /* # free inodes for non-root */ 115 | libssh2_uint64_t f_fsid; /* file system ID */ 116 | libssh2_uint64_t f_flag; /* mount flags */ 117 | libssh2_uint64_t f_namemax; /* maximum filename length */ 118 | }; 119 | 120 | /* SFTP filetypes */ 121 | #define LIBSSH2_SFTP_TYPE_REGULAR 1 122 | #define LIBSSH2_SFTP_TYPE_DIRECTORY 2 123 | #define LIBSSH2_SFTP_TYPE_SYMLINK 3 124 | #define LIBSSH2_SFTP_TYPE_SPECIAL 4 125 | #define LIBSSH2_SFTP_TYPE_UNKNOWN 5 126 | #define LIBSSH2_SFTP_TYPE_SOCKET 6 127 | #define LIBSSH2_SFTP_TYPE_CHAR_DEVICE 7 128 | #define LIBSSH2_SFTP_TYPE_BLOCK_DEVICE 8 129 | #define LIBSSH2_SFTP_TYPE_FIFO 9 130 | 131 | /* 132 | * Reproduce the POSIX file modes here for systems that are not POSIX 133 | * compliant. 134 | * 135 | * These is used in "permissions" of "struct _LIBSSH2_SFTP_ATTRIBUTES" 136 | */ 137 | /* File type */ 138 | #define LIBSSH2_SFTP_S_IFMT 0170000 /* type of file mask */ 139 | #define LIBSSH2_SFTP_S_IFIFO 0010000 /* named pipe (fifo) */ 140 | #define LIBSSH2_SFTP_S_IFCHR 0020000 /* character special */ 141 | #define LIBSSH2_SFTP_S_IFDIR 0040000 /* directory */ 142 | #define LIBSSH2_SFTP_S_IFBLK 0060000 /* block special */ 143 | #define LIBSSH2_SFTP_S_IFREG 0100000 /* regular */ 144 | #define LIBSSH2_SFTP_S_IFLNK 0120000 /* symbolic link */ 145 | #define LIBSSH2_SFTP_S_IFSOCK 0140000 /* socket */ 146 | 147 | /* File mode */ 148 | /* Read, write, execute/search by owner */ 149 | #define LIBSSH2_SFTP_S_IRWXU 0000700 /* RWX mask for owner */ 150 | #define LIBSSH2_SFTP_S_IRUSR 0000400 /* R for owner */ 151 | #define LIBSSH2_SFTP_S_IWUSR 0000200 /* W for owner */ 152 | #define LIBSSH2_SFTP_S_IXUSR 0000100 /* X for owner */ 153 | /* Read, write, execute/search by group */ 154 | #define LIBSSH2_SFTP_S_IRWXG 0000070 /* RWX mask for group */ 155 | #define LIBSSH2_SFTP_S_IRGRP 0000040 /* R for group */ 156 | #define LIBSSH2_SFTP_S_IWGRP 0000020 /* W for group */ 157 | #define LIBSSH2_SFTP_S_IXGRP 0000010 /* X for group */ 158 | /* Read, write, execute/search by others */ 159 | #define LIBSSH2_SFTP_S_IRWXO 0000007 /* RWX mask for other */ 160 | #define LIBSSH2_SFTP_S_IROTH 0000004 /* R for other */ 161 | #define LIBSSH2_SFTP_S_IWOTH 0000002 /* W for other */ 162 | #define LIBSSH2_SFTP_S_IXOTH 0000001 /* X for other */ 163 | 164 | /* macros to check for specific file types, added in 1.2.5 */ 165 | #define LIBSSH2_SFTP_S_ISLNK(m) \ 166 | (((m) & LIBSSH2_SFTP_S_IFMT) == LIBSSH2_SFTP_S_IFLNK) 167 | #define LIBSSH2_SFTP_S_ISREG(m) \ 168 | (((m) & LIBSSH2_SFTP_S_IFMT) == LIBSSH2_SFTP_S_IFREG) 169 | #define LIBSSH2_SFTP_S_ISDIR(m) \ 170 | (((m) & LIBSSH2_SFTP_S_IFMT) == LIBSSH2_SFTP_S_IFDIR) 171 | #define LIBSSH2_SFTP_S_ISCHR(m) \ 172 | (((m) & LIBSSH2_SFTP_S_IFMT) == LIBSSH2_SFTP_S_IFCHR) 173 | #define LIBSSH2_SFTP_S_ISBLK(m) \ 174 | (((m) & LIBSSH2_SFTP_S_IFMT) == LIBSSH2_SFTP_S_IFBLK) 175 | #define LIBSSH2_SFTP_S_ISFIFO(m) \ 176 | (((m) & LIBSSH2_SFTP_S_IFMT) == LIBSSH2_SFTP_S_IFIFO) 177 | #define LIBSSH2_SFTP_S_ISSOCK(m) \ 178 | (((m) & LIBSSH2_SFTP_S_IFMT) == LIBSSH2_SFTP_S_IFSOCK) 179 | 180 | /* SFTP File Transfer Flags -- (e.g. flags parameter to sftp_open()) 181 | * Danger will robinson... APPEND doesn't have any effect on OpenSSH servers */ 182 | #define LIBSSH2_FXF_READ 0x00000001 183 | #define LIBSSH2_FXF_WRITE 0x00000002 184 | #define LIBSSH2_FXF_APPEND 0x00000004 185 | #define LIBSSH2_FXF_CREAT 0x00000008 186 | #define LIBSSH2_FXF_TRUNC 0x00000010 187 | #define LIBSSH2_FXF_EXCL 0x00000020 188 | 189 | /* SFTP Status Codes (returned by libssh2_sftp_last_error() ) */ 190 | #define LIBSSH2_FX_OK 0 191 | #define LIBSSH2_FX_EOF 1 192 | #define LIBSSH2_FX_NO_SUCH_FILE 2 193 | #define LIBSSH2_FX_PERMISSION_DENIED 3 194 | #define LIBSSH2_FX_FAILURE 4 195 | #define LIBSSH2_FX_BAD_MESSAGE 5 196 | #define LIBSSH2_FX_NO_CONNECTION 6 197 | #define LIBSSH2_FX_CONNECTION_LOST 7 198 | #define LIBSSH2_FX_OP_UNSUPPORTED 8 199 | #define LIBSSH2_FX_INVALID_HANDLE 9 200 | #define LIBSSH2_FX_NO_SUCH_PATH 10 201 | #define LIBSSH2_FX_FILE_ALREADY_EXISTS 11 202 | #define LIBSSH2_FX_WRITE_PROTECT 12 203 | #define LIBSSH2_FX_NO_MEDIA 13 204 | #define LIBSSH2_FX_NO_SPACE_ON_FILESYSTEM 14 205 | #define LIBSSH2_FX_QUOTA_EXCEEDED 15 206 | #define LIBSSH2_FX_UNKNOWN_PRINCIPLE 16 /* Initial mis-spelling */ 207 | #define LIBSSH2_FX_UNKNOWN_PRINCIPAL 16 208 | #define LIBSSH2_FX_LOCK_CONFlICT 17 /* Initial mis-spelling */ 209 | #define LIBSSH2_FX_LOCK_CONFLICT 17 210 | #define LIBSSH2_FX_DIR_NOT_EMPTY 18 211 | #define LIBSSH2_FX_NOT_A_DIRECTORY 19 212 | #define LIBSSH2_FX_INVALID_FILENAME 20 213 | #define LIBSSH2_FX_LINK_LOOP 21 214 | 215 | /* Returned by any function that would block during a read/write opperation */ 216 | #define LIBSSH2SFTP_EAGAIN LIBSSH2_ERROR_EAGAIN 217 | 218 | /* SFTP API */ 219 | LIBSSH2_API LIBSSH2_SFTP *libssh2_sftp_init(LIBSSH2_SESSION *session); 220 | LIBSSH2_API int libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp); 221 | LIBSSH2_API unsigned long libssh2_sftp_last_error(LIBSSH2_SFTP *sftp); 222 | 223 | /* File / Directory Ops */ 224 | LIBSSH2_API LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp, 225 | const char *filename, 226 | unsigned int filename_len, 227 | unsigned long flags, 228 | long mode, int open_type); 229 | #define libssh2_sftp_open(sftp, filename, flags, mode) \ 230 | libssh2_sftp_open_ex((sftp), (filename), strlen(filename), (flags), \ 231 | (mode), LIBSSH2_SFTP_OPENFILE) 232 | #define libssh2_sftp_opendir(sftp, path) \ 233 | libssh2_sftp_open_ex((sftp), (path), strlen(path), 0, 0, \ 234 | LIBSSH2_SFTP_OPENDIR) 235 | 236 | LIBSSH2_API ssize_t libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *handle, 237 | char *buffer, size_t buffer_maxlen); 238 | 239 | LIBSSH2_API int libssh2_sftp_readdir_ex(LIBSSH2_SFTP_HANDLE *handle, \ 240 | char *buffer, size_t buffer_maxlen, 241 | char *longentry, 242 | size_t longentry_maxlen, 243 | LIBSSH2_SFTP_ATTRIBUTES *attrs); 244 | #define libssh2_sftp_readdir(handle, buffer, buffer_maxlen, attrs) \ 245 | libssh2_sftp_readdir_ex((handle), (buffer), (buffer_maxlen), NULL, 0, \ 246 | (attrs)) 247 | 248 | LIBSSH2_API ssize_t libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *handle, 249 | const char *buffer, size_t count); 250 | 251 | LIBSSH2_API int libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle); 252 | #define libssh2_sftp_close(handle) libssh2_sftp_close_handle(handle) 253 | #define libssh2_sftp_closedir(handle) libssh2_sftp_close_handle(handle) 254 | 255 | LIBSSH2_API void libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE *handle, size_t offset); 256 | LIBSSH2_API void libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, 257 | libssh2_uint64_t offset); 258 | #define libssh2_sftp_rewind(handle) libssh2_sftp_seek64((handle), 0) 259 | 260 | LIBSSH2_API size_t libssh2_sftp_tell(LIBSSH2_SFTP_HANDLE *handle); 261 | LIBSSH2_API libssh2_uint64_t libssh2_sftp_tell64(LIBSSH2_SFTP_HANDLE *handle); 262 | 263 | LIBSSH2_API int libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *handle, 264 | LIBSSH2_SFTP_ATTRIBUTES *attrs, 265 | int setstat); 266 | #define libssh2_sftp_fstat(handle, attrs) \ 267 | libssh2_sftp_fstat_ex((handle), (attrs), 0) 268 | #define libssh2_sftp_fsetstat(handle, attrs) \ 269 | libssh2_sftp_fstat_ex((handle), (attrs), 1) 270 | 271 | /* Miscellaneous Ops */ 272 | LIBSSH2_API int libssh2_sftp_rename_ex(LIBSSH2_SFTP *sftp, 273 | const char *source_filename, 274 | unsigned int srouce_filename_len, 275 | const char *dest_filename, 276 | unsigned int dest_filename_len, 277 | long flags); 278 | #define libssh2_sftp_rename(sftp, sourcefile, destfile) \ 279 | libssh2_sftp_rename_ex((sftp), (sourcefile), strlen(sourcefile), \ 280 | (destfile), strlen(destfile), \ 281 | LIBSSH2_SFTP_RENAME_OVERWRITE | \ 282 | LIBSSH2_SFTP_RENAME_ATOMIC | \ 283 | LIBSSH2_SFTP_RENAME_NATIVE) 284 | 285 | LIBSSH2_API int libssh2_sftp_unlink_ex(LIBSSH2_SFTP *sftp, 286 | const char *filename, 287 | unsigned int filename_len); 288 | #define libssh2_sftp_unlink(sftp, filename) \ 289 | libssh2_sftp_unlink_ex((sftp), (filename), strlen(filename)) 290 | 291 | LIBSSH2_API int libssh2_sftp_fstatvfs(LIBSSH2_SFTP_HANDLE *handle, 292 | LIBSSH2_SFTP_STATVFS *st); 293 | 294 | LIBSSH2_API int libssh2_sftp_statvfs(LIBSSH2_SFTP *sftp, 295 | const char *path, 296 | size_t path_len, 297 | LIBSSH2_SFTP_STATVFS *st); 298 | 299 | LIBSSH2_API int libssh2_sftp_mkdir_ex(LIBSSH2_SFTP *sftp, 300 | const char *path, 301 | unsigned int path_len, long mode); 302 | #define libssh2_sftp_mkdir(sftp, path, mode) \ 303 | libssh2_sftp_mkdir_ex((sftp), (path), strlen(path), (mode)) 304 | 305 | LIBSSH2_API int libssh2_sftp_rmdir_ex(LIBSSH2_SFTP *sftp, 306 | const char *path, 307 | unsigned int path_len); 308 | #define libssh2_sftp_rmdir(sftp, path) \ 309 | libssh2_sftp_rmdir_ex((sftp), (path), strlen(path)) 310 | 311 | LIBSSH2_API int libssh2_sftp_stat_ex(LIBSSH2_SFTP *sftp, 312 | const char *path, 313 | unsigned int path_len, 314 | int stat_type, 315 | LIBSSH2_SFTP_ATTRIBUTES *attrs); 316 | #define libssh2_sftp_stat(sftp, path, attrs) \ 317 | libssh2_sftp_stat_ex((sftp), (path), strlen(path), LIBSSH2_SFTP_STAT, \ 318 | (attrs)) 319 | #define libssh2_sftp_lstat(sftp, path, attrs) \ 320 | libssh2_sftp_stat_ex((sftp), (path), strlen(path), LIBSSH2_SFTP_LSTAT, \ 321 | (attrs)) 322 | #define libssh2_sftp_setstat(sftp, path, attrs) \ 323 | libssh2_sftp_stat_ex((sftp), (path), strlen(path), LIBSSH2_SFTP_SETSTAT, \ 324 | (attrs)) 325 | 326 | LIBSSH2_API int libssh2_sftp_symlink_ex(LIBSSH2_SFTP *sftp, 327 | const char *path, 328 | unsigned int path_len, 329 | char *target, 330 | unsigned int target_len, int link_type); 331 | #define libssh2_sftp_symlink(sftp, orig, linkpath) \ 332 | libssh2_sftp_symlink_ex((sftp), (orig), strlen(orig), (linkpath), \ 333 | strlen(linkpath), LIBSSH2_SFTP_SYMLINK) 334 | #define libssh2_sftp_readlink(sftp, path, target, maxlen) \ 335 | libssh2_sftp_symlink_ex((sftp), (path), strlen(path), (target), (maxlen), \ 336 | LIBSSH2_SFTP_READLINK) 337 | #define libssh2_sftp_realpath(sftp, path, target, maxlen) \ 338 | libssh2_sftp_symlink_ex((sftp), (path), strlen(path), (target), (maxlen), \ 339 | LIBSSH2_SFTP_REALPATH) 340 | 341 | #ifdef __cplusplus 342 | } /* extern "C" */ 343 | #endif 344 | 345 | #endif /* LIBSSH2_SFTP_H */ 346 | -------------------------------------------------------------------------------- /SSHCore/en.lproj/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1024 5 | 10D571 6 | 786 7 | 1038.29 8 | 460.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 112 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | IBCocoaTouchFramework 35 | 36 | 37 | IBFirstResponder 38 | IBCocoaTouchFramework 39 | 40 | 41 | IBCocoaTouchFramework 42 | 43 | 44 | SSHCoreViewController 45 | 46 | 47 | 1 48 | 49 | IBCocoaTouchFramework 50 | NO 51 | 52 | 53 | 54 | 292 55 | {320, 480} 56 | 57 | 1 58 | MSAxIDEAA 59 | 60 | NO 61 | NO 62 | 63 | IBCocoaTouchFramework 64 | YES 65 | 66 | 67 | 68 | 69 | YES 70 | 71 | 72 | delegate 73 | 74 | 75 | 76 | 4 77 | 78 | 79 | 80 | viewController 81 | 82 | 83 | 84 | 11 85 | 86 | 87 | 88 | window 89 | 90 | 91 | 92 | 14 93 | 94 | 95 | 96 | 97 | YES 98 | 99 | 0 100 | 101 | 102 | 103 | 104 | 105 | -1 106 | 107 | 108 | File's Owner 109 | 110 | 111 | 3 112 | 113 | 114 | SSHCore App Delegate 115 | 116 | 117 | -2 118 | 119 | 120 | 121 | 122 | 10 123 | 124 | 125 | 126 | 127 | 12 128 | 129 | 130 | 131 | 132 | 133 | 134 | YES 135 | 136 | YES 137 | -1.CustomClassName 138 | -2.CustomClassName 139 | 10.CustomClassName 140 | 10.IBEditorWindowLastContentRect 141 | 10.IBPluginDependency 142 | 12.IBEditorWindowLastContentRect 143 | 12.IBPluginDependency 144 | 3.CustomClassName 145 | 3.IBPluginDependency 146 | 147 | 148 | YES 149 | UIApplication 150 | UIResponder 151 | SSHCoreViewController 152 | {{234, 376}, {320, 480}} 153 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 154 | {{525, 346}, {320, 480}} 155 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 156 | SSHCoreAppDelegate 157 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 158 | 159 | 160 | 161 | YES 162 | 163 | 164 | YES 165 | 166 | 167 | 168 | 169 | YES 170 | 171 | 172 | YES 173 | 174 | 175 | 176 | 15 177 | 178 | 179 | 180 | YES 181 | 182 | UIWindow 183 | UIView 184 | 185 | IBUserSource 186 | 187 | 188 | 189 | 190 | SSHCoreAppDelegate 191 | NSObject 192 | 193 | YES 194 | 195 | YES 196 | viewController 197 | window 198 | 199 | 200 | YES 201 | SSHCoreViewController 202 | UIWindow 203 | 204 | 205 | 206 | YES 207 | 208 | YES 209 | viewController 210 | window 211 | 212 | 213 | YES 214 | 215 | viewController 216 | SSHCoreViewController 217 | 218 | 219 | window 220 | UIWindow 221 | 222 | 223 | 224 | 225 | IBProjectSource 226 | SSHCoreAppDelegate.h 227 | 228 | 229 | 230 | SSHCoreAppDelegate 231 | NSObject 232 | 233 | IBUserSource 234 | 235 | 236 | 237 | 238 | SSHCoreViewController 239 | UIViewController 240 | 241 | IBProjectSource 242 | SSHCoreViewController.h 243 | 244 | 245 | 246 | 247 | YES 248 | 249 | NSObject 250 | 251 | IBFrameworkSource 252 | Foundation.framework/Headers/NSError.h 253 | 254 | 255 | 256 | NSObject 257 | 258 | IBFrameworkSource 259 | Foundation.framework/Headers/NSFileManager.h 260 | 261 | 262 | 263 | NSObject 264 | 265 | IBFrameworkSource 266 | Foundation.framework/Headers/NSKeyValueCoding.h 267 | 268 | 269 | 270 | NSObject 271 | 272 | IBFrameworkSource 273 | Foundation.framework/Headers/NSKeyValueObserving.h 274 | 275 | 276 | 277 | NSObject 278 | 279 | IBFrameworkSource 280 | Foundation.framework/Headers/NSKeyedArchiver.h 281 | 282 | 283 | 284 | NSObject 285 | 286 | IBFrameworkSource 287 | Foundation.framework/Headers/NSObject.h 288 | 289 | 290 | 291 | NSObject 292 | 293 | IBFrameworkSource 294 | Foundation.framework/Headers/NSRunLoop.h 295 | 296 | 297 | 298 | NSObject 299 | 300 | IBFrameworkSource 301 | Foundation.framework/Headers/NSThread.h 302 | 303 | 304 | 305 | NSObject 306 | 307 | IBFrameworkSource 308 | Foundation.framework/Headers/NSURL.h 309 | 310 | 311 | 312 | NSObject 313 | 314 | IBFrameworkSource 315 | Foundation.framework/Headers/NSURLConnection.h 316 | 317 | 318 | 319 | NSObject 320 | 321 | IBFrameworkSource 322 | UIKit.framework/Headers/UIAccessibility.h 323 | 324 | 325 | 326 | NSObject 327 | 328 | IBFrameworkSource 329 | UIKit.framework/Headers/UINibLoading.h 330 | 331 | 332 | 333 | NSObject 334 | 335 | IBFrameworkSource 336 | UIKit.framework/Headers/UIResponder.h 337 | 338 | 339 | 340 | UIApplication 341 | UIResponder 342 | 343 | IBFrameworkSource 344 | UIKit.framework/Headers/UIApplication.h 345 | 346 | 347 | 348 | UIResponder 349 | NSObject 350 | 351 | 352 | 353 | UISearchBar 354 | UIView 355 | 356 | IBFrameworkSource 357 | UIKit.framework/Headers/UISearchBar.h 358 | 359 | 360 | 361 | UISearchDisplayController 362 | NSObject 363 | 364 | IBFrameworkSource 365 | UIKit.framework/Headers/UISearchDisplayController.h 366 | 367 | 368 | 369 | UIView 370 | 371 | IBFrameworkSource 372 | UIKit.framework/Headers/UITextField.h 373 | 374 | 375 | 376 | UIView 377 | UIResponder 378 | 379 | IBFrameworkSource 380 | UIKit.framework/Headers/UIView.h 381 | 382 | 383 | 384 | UIViewController 385 | 386 | IBFrameworkSource 387 | UIKit.framework/Headers/UINavigationController.h 388 | 389 | 390 | 391 | UIViewController 392 | 393 | IBFrameworkSource 394 | UIKit.framework/Headers/UIPopoverController.h 395 | 396 | 397 | 398 | UIViewController 399 | 400 | IBFrameworkSource 401 | UIKit.framework/Headers/UISplitViewController.h 402 | 403 | 404 | 405 | UIViewController 406 | 407 | IBFrameworkSource 408 | UIKit.framework/Headers/UITabBarController.h 409 | 410 | 411 | 412 | UIViewController 413 | UIResponder 414 | 415 | IBFrameworkSource 416 | UIKit.framework/Headers/UIViewController.h 417 | 418 | 419 | 420 | UIWindow 421 | UIView 422 | 423 | IBFrameworkSource 424 | UIKit.framework/Headers/UIWindow.h 425 | 426 | 427 | 428 | 429 | 0 430 | IBCocoaTouchFramework 431 | 432 | com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS 433 | 434 | 435 | 436 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 437 | 438 | 439 | YES 440 | SSHCore.xcodeproj 441 | 3 442 | 112 443 | 444 | 445 | -------------------------------------------------------------------------------- /SSHCore.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F2897B6F1395F36D009FAA05 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897B6E1395F36D009FAA05 /* UIKit.framework */; }; 11 | F2897B711395F36D009FAA05 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897B701395F36D009FAA05 /* Foundation.framework */; }; 12 | F2897B731395F36D009FAA05 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897B721395F36D009FAA05 /* CoreGraphics.framework */; }; 13 | F2897B791395F36D009FAA05 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F2897B771395F36D009FAA05 /* InfoPlist.strings */; }; 14 | F2897B7C1395F36D009FAA05 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F2897B7B1395F36D009FAA05 /* main.m */; }; 15 | F2897B7F1395F36D009FAA05 /* SSHCoreAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F2897B7E1395F36D009FAA05 /* SSHCoreAppDelegate.m */; }; 16 | F2897B821395F36D009FAA05 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = F2897B801395F36D009FAA05 /* MainWindow.xib */; }; 17 | F2897B851395F36D009FAA05 /* SSHCoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F2897B841395F36D009FAA05 /* SSHCoreViewController.m */; }; 18 | F2897B881395F36D009FAA05 /* SSHCoreViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F2897B861395F36D009FAA05 /* SSHCoreViewController.xib */; }; 19 | F2897B8F1395F36D009FAA05 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897B6E1395F36D009FAA05 /* UIKit.framework */; }; 20 | F2897B901395F36D009FAA05 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897B701395F36D009FAA05 /* Foundation.framework */; }; 21 | F2897B911395F36D009FAA05 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897B721395F36D009FAA05 /* CoreGraphics.framework */; }; 22 | F2897B991395F36D009FAA05 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F2897B971395F36D009FAA05 /* InfoPlist.strings */; }; 23 | F2897B9C1395F36D009FAA05 /* SSHCoreTests.h in Resources */ = {isa = PBXBuildFile; fileRef = F2897B9B1395F36D009FAA05 /* SSHCoreTests.h */; }; 24 | F2897B9E1395F36D009FAA05 /* SSHCoreTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F2897B9D1395F36D009FAA05 /* SSHCoreTests.m */; }; 25 | F2897BB81395F768009FAA05 /* libgcrypt.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897BB01395F768009FAA05 /* libgcrypt.a */; }; 26 | F2897BB91395F768009FAA05 /* libgpg-error.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897BB11395F768009FAA05 /* libgpg-error.a */; }; 27 | F2897BBA1395F768009FAA05 /* libssh2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F2897BB51395F768009FAA05 /* libssh2.a */; }; 28 | F2897BBB1395F768009FAA05 /* simulator.m in Sources */ = {isa = PBXBuildFile; fileRef = F2897BB71395F768009FAA05 /* simulator.m */; }; 29 | F2897BBE1395F925009FAA05 /* SSHCore.m in Sources */ = {isa = PBXBuildFile; fileRef = F2897BBD1395F925009FAA05 /* SSHCore.m */; }; 30 | /* End PBXBuildFile section */ 31 | 32 | /* Begin PBXContainerItemProxy section */ 33 | F2897B921395F36D009FAA05 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = F2897B611395F36C009FAA05 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = F2897B691395F36D009FAA05; 38 | remoteInfo = SSHCore; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | F2897B6A1395F36D009FAA05 /* SSHCore.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SSHCore.app; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | F2897B6E1395F36D009FAA05 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 45 | F2897B701395F36D009FAA05 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 46 | F2897B721395F36D009FAA05 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 47 | F2897B761395F36D009FAA05 /* SSHCore-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SSHCore-Info.plist"; sourceTree = ""; }; 48 | F2897B781395F36D009FAA05 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 49 | F2897B7A1395F36D009FAA05 /* SSHCore-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SSHCore-Prefix.pch"; sourceTree = ""; }; 50 | F2897B7B1395F36D009FAA05 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 51 | F2897B7D1395F36D009FAA05 /* SSHCoreAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SSHCoreAppDelegate.h; sourceTree = ""; }; 52 | F2897B7E1395F36D009FAA05 /* SSHCoreAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SSHCoreAppDelegate.m; sourceTree = ""; }; 53 | F2897B811395F36D009FAA05 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = ""; }; 54 | F2897B831395F36D009FAA05 /* SSHCoreViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SSHCoreViewController.h; sourceTree = ""; }; 55 | F2897B841395F36D009FAA05 /* SSHCoreViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SSHCoreViewController.m; sourceTree = ""; }; 56 | F2897B871395F36D009FAA05 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/SSHCoreViewController.xib; sourceTree = ""; }; 57 | F2897B8E1395F36D009FAA05 /* SSHCoreTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SSHCoreTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | F2897B961395F36D009FAA05 /* SSHCoreTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SSHCoreTests-Info.plist"; sourceTree = ""; }; 59 | F2897B981395F36D009FAA05 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 60 | F2897B9A1395F36D009FAA05 /* SSHCoreTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SSHCoreTests-Prefix.pch"; sourceTree = ""; }; 61 | F2897B9B1395F36D009FAA05 /* SSHCoreTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SSHCoreTests.h; sourceTree = ""; }; 62 | F2897B9D1395F36D009FAA05 /* SSHCoreTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SSHCoreTests.m; sourceTree = ""; }; 63 | F2897BB01395F768009FAA05 /* libgcrypt.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgcrypt.a; sourceTree = ""; }; 64 | F2897BB11395F768009FAA05 /* libgpg-error.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libgpg-error.a"; sourceTree = ""; }; 65 | F2897BB21395F768009FAA05 /* libssh2_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libssh2_config.h; sourceTree = ""; }; 66 | F2897BB31395F768009FAA05 /* libssh2_publickey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libssh2_publickey.h; sourceTree = ""; }; 67 | F2897BB41395F768009FAA05 /* libssh2_sftp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libssh2_sftp.h; sourceTree = ""; }; 68 | F2897BB51395F768009FAA05 /* libssh2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libssh2.a; sourceTree = ""; }; 69 | F2897BB61395F768009FAA05 /* libssh2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libssh2.h; sourceTree = ""; }; 70 | F2897BB71395F768009FAA05 /* simulator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = simulator.m; sourceTree = ""; }; 71 | F2897BBC1395F925009FAA05 /* SSHCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSHCore.h; sourceTree = ""; }; 72 | F2897BBD1395F925009FAA05 /* SSHCore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSHCore.m; sourceTree = ""; }; 73 | /* End PBXFileReference section */ 74 | 75 | /* Begin PBXFrameworksBuildPhase section */ 76 | F2897B671395F36D009FAA05 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | F2897B6F1395F36D009FAA05 /* UIKit.framework in Frameworks */, 81 | F2897B711395F36D009FAA05 /* Foundation.framework in Frameworks */, 82 | F2897B731395F36D009FAA05 /* CoreGraphics.framework in Frameworks */, 83 | F2897BB81395F768009FAA05 /* libgcrypt.a in Frameworks */, 84 | F2897BB91395F768009FAA05 /* libgpg-error.a in Frameworks */, 85 | F2897BBA1395F768009FAA05 /* libssh2.a in Frameworks */, 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | F2897B8A1395F36D009FAA05 /* Frameworks */ = { 90 | isa = PBXFrameworksBuildPhase; 91 | buildActionMask = 2147483647; 92 | files = ( 93 | F2897B8F1395F36D009FAA05 /* UIKit.framework in Frameworks */, 94 | F2897B901395F36D009FAA05 /* Foundation.framework in Frameworks */, 95 | F2897B911395F36D009FAA05 /* CoreGraphics.framework in Frameworks */, 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | /* End PBXFrameworksBuildPhase section */ 100 | 101 | /* Begin PBXGroup section */ 102 | F2897B5F1395F36C009FAA05 = { 103 | isa = PBXGroup; 104 | children = ( 105 | F2897B741395F36D009FAA05 /* SSHCore */, 106 | F2897B941395F36D009FAA05 /* SSHCoreTests */, 107 | F2897B6D1395F36D009FAA05 /* Frameworks */, 108 | F2897B6B1395F36D009FAA05 /* Products */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | F2897B6B1395F36D009FAA05 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | F2897B6A1395F36D009FAA05 /* SSHCore.app */, 116 | F2897B8E1395F36D009FAA05 /* SSHCoreTests.octest */, 117 | ); 118 | name = Products; 119 | sourceTree = ""; 120 | }; 121 | F2897B6D1395F36D009FAA05 /* Frameworks */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | F2897B6E1395F36D009FAA05 /* UIKit.framework */, 125 | F2897B701395F36D009FAA05 /* Foundation.framework */, 126 | F2897B721395F36D009FAA05 /* CoreGraphics.framework */, 127 | ); 128 | name = Frameworks; 129 | sourceTree = ""; 130 | }; 131 | F2897B741395F36D009FAA05 /* SSHCore */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | F2897BBC1395F925009FAA05 /* SSHCore.h */, 135 | F2897BBD1395F925009FAA05 /* SSHCore.m */, 136 | F2897B7D1395F36D009FAA05 /* SSHCoreAppDelegate.h */, 137 | F2897B7E1395F36D009FAA05 /* SSHCoreAppDelegate.m */, 138 | F2897B801395F36D009FAA05 /* MainWindow.xib */, 139 | F2897B831395F36D009FAA05 /* SSHCoreViewController.h */, 140 | F2897B841395F36D009FAA05 /* SSHCoreViewController.m */, 141 | F2897B861395F36D009FAA05 /* SSHCoreViewController.xib */, 142 | F2897B751395F36D009FAA05 /* Supporting Files */, 143 | ); 144 | path = SSHCore; 145 | sourceTree = ""; 146 | }; 147 | F2897B751395F36D009FAA05 /* Supporting Files */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | F2897BAF1395F746009FAA05 /* Libraries */, 151 | F2897B761395F36D009FAA05 /* SSHCore-Info.plist */, 152 | F2897B771395F36D009FAA05 /* InfoPlist.strings */, 153 | F2897B7A1395F36D009FAA05 /* SSHCore-Prefix.pch */, 154 | F2897B7B1395F36D009FAA05 /* main.m */, 155 | ); 156 | name = "Supporting Files"; 157 | sourceTree = ""; 158 | }; 159 | F2897B941395F36D009FAA05 /* SSHCoreTests */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | F2897B9B1395F36D009FAA05 /* SSHCoreTests.h */, 163 | F2897B9D1395F36D009FAA05 /* SSHCoreTests.m */, 164 | F2897B951395F36D009FAA05 /* Supporting Files */, 165 | ); 166 | path = SSHCoreTests; 167 | sourceTree = ""; 168 | }; 169 | F2897B951395F36D009FAA05 /* Supporting Files */ = { 170 | isa = PBXGroup; 171 | children = ( 172 | F2897B961395F36D009FAA05 /* SSHCoreTests-Info.plist */, 173 | F2897B971395F36D009FAA05 /* InfoPlist.strings */, 174 | F2897B9A1395F36D009FAA05 /* SSHCoreTests-Prefix.pch */, 175 | ); 176 | name = "Supporting Files"; 177 | sourceTree = ""; 178 | }; 179 | F2897BAF1395F746009FAA05 /* Libraries */ = { 180 | isa = PBXGroup; 181 | children = ( 182 | F2897BB01395F768009FAA05 /* libgcrypt.a */, 183 | F2897BB11395F768009FAA05 /* libgpg-error.a */, 184 | F2897BB21395F768009FAA05 /* libssh2_config.h */, 185 | F2897BB31395F768009FAA05 /* libssh2_publickey.h */, 186 | F2897BB41395F768009FAA05 /* libssh2_sftp.h */, 187 | F2897BB51395F768009FAA05 /* libssh2.a */, 188 | F2897BB61395F768009FAA05 /* libssh2.h */, 189 | F2897BB71395F768009FAA05 /* simulator.m */, 190 | ); 191 | name = Libraries; 192 | sourceTree = ""; 193 | }; 194 | /* End PBXGroup section */ 195 | 196 | /* Begin PBXNativeTarget section */ 197 | F2897B691395F36D009FAA05 /* SSHCore */ = { 198 | isa = PBXNativeTarget; 199 | buildConfigurationList = F2897BA11395F36D009FAA05 /* Build configuration list for PBXNativeTarget "SSHCore" */; 200 | buildPhases = ( 201 | F2897B661395F36D009FAA05 /* Sources */, 202 | F2897B671395F36D009FAA05 /* Frameworks */, 203 | F2897B681395F36D009FAA05 /* Resources */, 204 | ); 205 | buildRules = ( 206 | ); 207 | dependencies = ( 208 | ); 209 | name = SSHCore; 210 | productName = SSHCore; 211 | productReference = F2897B6A1395F36D009FAA05 /* SSHCore.app */; 212 | productType = "com.apple.product-type.application"; 213 | }; 214 | F2897B8D1395F36D009FAA05 /* SSHCoreTests */ = { 215 | isa = PBXNativeTarget; 216 | buildConfigurationList = F2897BA41395F36D009FAA05 /* Build configuration list for PBXNativeTarget "SSHCoreTests" */; 217 | buildPhases = ( 218 | F2897B891395F36D009FAA05 /* Sources */, 219 | F2897B8A1395F36D009FAA05 /* Frameworks */, 220 | F2897B8B1395F36D009FAA05 /* Resources */, 221 | F2897B8C1395F36D009FAA05 /* ShellScript */, 222 | ); 223 | buildRules = ( 224 | ); 225 | dependencies = ( 226 | F2897B931395F36D009FAA05 /* PBXTargetDependency */, 227 | ); 228 | name = SSHCoreTests; 229 | productName = SSHCoreTests; 230 | productReference = F2897B8E1395F36D009FAA05 /* SSHCoreTests.octest */; 231 | productType = "com.apple.product-type.bundle"; 232 | }; 233 | /* End PBXNativeTarget section */ 234 | 235 | /* Begin PBXProject section */ 236 | F2897B611395F36C009FAA05 /* Project object */ = { 237 | isa = PBXProject; 238 | buildConfigurationList = F2897B641395F36C009FAA05 /* Build configuration list for PBXProject "SSHCore" */; 239 | compatibilityVersion = "Xcode 3.2"; 240 | developmentRegion = English; 241 | hasScannedForEncodings = 0; 242 | knownRegions = ( 243 | en, 244 | ); 245 | mainGroup = F2897B5F1395F36C009FAA05; 246 | productRefGroup = F2897B6B1395F36D009FAA05 /* Products */; 247 | projectDirPath = ""; 248 | projectRoot = ""; 249 | targets = ( 250 | F2897B691395F36D009FAA05 /* SSHCore */, 251 | F2897B8D1395F36D009FAA05 /* SSHCoreTests */, 252 | ); 253 | }; 254 | /* End PBXProject section */ 255 | 256 | /* Begin PBXResourcesBuildPhase section */ 257 | F2897B681395F36D009FAA05 /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | F2897B791395F36D009FAA05 /* InfoPlist.strings in Resources */, 262 | F2897B821395F36D009FAA05 /* MainWindow.xib in Resources */, 263 | F2897B881395F36D009FAA05 /* SSHCoreViewController.xib in Resources */, 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | F2897B8B1395F36D009FAA05 /* Resources */ = { 268 | isa = PBXResourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | F2897B991395F36D009FAA05 /* InfoPlist.strings in Resources */, 272 | F2897B9C1395F36D009FAA05 /* SSHCoreTests.h in Resources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXResourcesBuildPhase section */ 277 | 278 | /* Begin PBXShellScriptBuildPhase section */ 279 | F2897B8C1395F36D009FAA05 /* ShellScript */ = { 280 | isa = PBXShellScriptBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | ); 284 | inputPaths = ( 285 | ); 286 | outputPaths = ( 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | shellPath = /bin/sh; 290 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 291 | }; 292 | /* End PBXShellScriptBuildPhase section */ 293 | 294 | /* Begin PBXSourcesBuildPhase section */ 295 | F2897B661395F36D009FAA05 /* Sources */ = { 296 | isa = PBXSourcesBuildPhase; 297 | buildActionMask = 2147483647; 298 | files = ( 299 | F2897B7C1395F36D009FAA05 /* main.m in Sources */, 300 | F2897B7F1395F36D009FAA05 /* SSHCoreAppDelegate.m in Sources */, 301 | F2897B851395F36D009FAA05 /* SSHCoreViewController.m in Sources */, 302 | F2897BBB1395F768009FAA05 /* simulator.m in Sources */, 303 | F2897BBE1395F925009FAA05 /* SSHCore.m in Sources */, 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | }; 307 | F2897B891395F36D009FAA05 /* Sources */ = { 308 | isa = PBXSourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | F2897B9E1395F36D009FAA05 /* SSHCoreTests.m in Sources */, 312 | ); 313 | runOnlyForDeploymentPostprocessing = 0; 314 | }; 315 | /* End PBXSourcesBuildPhase section */ 316 | 317 | /* Begin PBXTargetDependency section */ 318 | F2897B931395F36D009FAA05 /* PBXTargetDependency */ = { 319 | isa = PBXTargetDependency; 320 | target = F2897B691395F36D009FAA05 /* SSHCore */; 321 | targetProxy = F2897B921395F36D009FAA05 /* PBXContainerItemProxy */; 322 | }; 323 | /* End PBXTargetDependency section */ 324 | 325 | /* Begin PBXVariantGroup section */ 326 | F2897B771395F36D009FAA05 /* InfoPlist.strings */ = { 327 | isa = PBXVariantGroup; 328 | children = ( 329 | F2897B781395F36D009FAA05 /* en */, 330 | ); 331 | name = InfoPlist.strings; 332 | sourceTree = ""; 333 | }; 334 | F2897B801395F36D009FAA05 /* MainWindow.xib */ = { 335 | isa = PBXVariantGroup; 336 | children = ( 337 | F2897B811395F36D009FAA05 /* en */, 338 | ); 339 | name = MainWindow.xib; 340 | sourceTree = ""; 341 | }; 342 | F2897B861395F36D009FAA05 /* SSHCoreViewController.xib */ = { 343 | isa = PBXVariantGroup; 344 | children = ( 345 | F2897B871395F36D009FAA05 /* en */, 346 | ); 347 | name = SSHCoreViewController.xib; 348 | sourceTree = ""; 349 | }; 350 | F2897B971395F36D009FAA05 /* InfoPlist.strings */ = { 351 | isa = PBXVariantGroup; 352 | children = ( 353 | F2897B981395F36D009FAA05 /* en */, 354 | ); 355 | name = InfoPlist.strings; 356 | sourceTree = ""; 357 | }; 358 | /* End PBXVariantGroup section */ 359 | 360 | /* Begin XCBuildConfiguration section */ 361 | F2897B9F1395F36D009FAA05 /* Debug */ = { 362 | isa = XCBuildConfiguration; 363 | buildSettings = { 364 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | GCC_C_LANGUAGE_STANDARD = gnu99; 367 | GCC_OPTIMIZATION_LEVEL = 0; 368 | GCC_PREPROCESSOR_DEFINITIONS = DEBUG; 369 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 370 | GCC_VERSION = com.apple.compilers.llvmgcc42; 371 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 372 | GCC_WARN_UNUSED_VARIABLE = YES; 373 | IPHONEOS_DEPLOYMENT_TARGET = 4.3; 374 | SDKROOT = iphoneos; 375 | }; 376 | name = Debug; 377 | }; 378 | F2897BA01395F36D009FAA05 /* Release */ = { 379 | isa = XCBuildConfiguration; 380 | buildSettings = { 381 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 382 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 383 | GCC_C_LANGUAGE_STANDARD = gnu99; 384 | GCC_VERSION = com.apple.compilers.llvmgcc42; 385 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 386 | GCC_WARN_UNUSED_VARIABLE = YES; 387 | IPHONEOS_DEPLOYMENT_TARGET = 4.3; 388 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 389 | SDKROOT = iphoneos; 390 | }; 391 | name = Release; 392 | }; 393 | F2897BA21395F36D009FAA05 /* Debug */ = { 394 | isa = XCBuildConfiguration; 395 | buildSettings = { 396 | ALWAYS_SEARCH_USER_PATHS = NO; 397 | COPY_PHASE_STRIP = NO; 398 | GCC_DYNAMIC_NO_PIC = NO; 399 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 400 | GCC_PREFIX_HEADER = "SSHCore/SSHCore-Prefix.pch"; 401 | INFOPLIST_FILE = "SSHCore/SSHCore-Info.plist"; 402 | LIBRARY_SEARCH_PATHS = ( 403 | "$(inherited)", 404 | "\"$(SRCROOT)/SSHCore\"", 405 | ); 406 | OTHER_LDFLAGS = "-lz"; 407 | PRODUCT_NAME = "$(TARGET_NAME)"; 408 | WRAPPER_EXTENSION = app; 409 | }; 410 | name = Debug; 411 | }; 412 | F2897BA31395F36D009FAA05 /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | ALWAYS_SEARCH_USER_PATHS = NO; 416 | COPY_PHASE_STRIP = YES; 417 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 418 | GCC_PREFIX_HEADER = "SSHCore/SSHCore-Prefix.pch"; 419 | INFOPLIST_FILE = "SSHCore/SSHCore-Info.plist"; 420 | LIBRARY_SEARCH_PATHS = ( 421 | "$(inherited)", 422 | "\"$(SRCROOT)/SSHCore\"", 423 | ); 424 | OTHER_LDFLAGS = "-lz"; 425 | PRODUCT_NAME = "$(TARGET_NAME)"; 426 | VALIDATE_PRODUCT = YES; 427 | WRAPPER_EXTENSION = app; 428 | }; 429 | name = Release; 430 | }; 431 | F2897BA51395F36D009FAA05 /* Debug */ = { 432 | isa = XCBuildConfiguration; 433 | buildSettings = { 434 | ALWAYS_SEARCH_USER_PATHS = NO; 435 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SSHCore.app/SSHCore"; 436 | FRAMEWORK_SEARCH_PATHS = ( 437 | "$(SDKROOT)/Developer/Library/Frameworks", 438 | "$(DEVELOPER_LIBRARY_DIR)/Frameworks", 439 | ); 440 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 441 | GCC_PREFIX_HEADER = "SSHCoreTests/SSHCoreTests-Prefix.pch"; 442 | INFOPLIST_FILE = "SSHCoreTests/SSHCoreTests-Info.plist"; 443 | OTHER_LDFLAGS = ( 444 | "-framework", 445 | SenTestingKit, 446 | ); 447 | PRODUCT_NAME = "$(TARGET_NAME)"; 448 | TEST_HOST = "$(BUNDLE_LOADER)"; 449 | WRAPPER_EXTENSION = octest; 450 | }; 451 | name = Debug; 452 | }; 453 | F2897BA61395F36D009FAA05 /* Release */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ALWAYS_SEARCH_USER_PATHS = NO; 457 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SSHCore.app/SSHCore"; 458 | FRAMEWORK_SEARCH_PATHS = ( 459 | "$(SDKROOT)/Developer/Library/Frameworks", 460 | "$(DEVELOPER_LIBRARY_DIR)/Frameworks", 461 | ); 462 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 463 | GCC_PREFIX_HEADER = "SSHCoreTests/SSHCoreTests-Prefix.pch"; 464 | INFOPLIST_FILE = "SSHCoreTests/SSHCoreTests-Info.plist"; 465 | OTHER_LDFLAGS = ( 466 | "-framework", 467 | SenTestingKit, 468 | ); 469 | PRODUCT_NAME = "$(TARGET_NAME)"; 470 | TEST_HOST = "$(BUNDLE_LOADER)"; 471 | WRAPPER_EXTENSION = octest; 472 | }; 473 | name = Release; 474 | }; 475 | /* End XCBuildConfiguration section */ 476 | 477 | /* Begin XCConfigurationList section */ 478 | F2897B641395F36C009FAA05 /* Build configuration list for PBXProject "SSHCore" */ = { 479 | isa = XCConfigurationList; 480 | buildConfigurations = ( 481 | F2897B9F1395F36D009FAA05 /* Debug */, 482 | F2897BA01395F36D009FAA05 /* Release */, 483 | ); 484 | defaultConfigurationIsVisible = 0; 485 | defaultConfigurationName = Release; 486 | }; 487 | F2897BA11395F36D009FAA05 /* Build configuration list for PBXNativeTarget "SSHCore" */ = { 488 | isa = XCConfigurationList; 489 | buildConfigurations = ( 490 | F2897BA21395F36D009FAA05 /* Debug */, 491 | F2897BA31395F36D009FAA05 /* Release */, 492 | ); 493 | defaultConfigurationIsVisible = 0; 494 | }; 495 | F2897BA41395F36D009FAA05 /* Build configuration list for PBXNativeTarget "SSHCoreTests" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | F2897BA51395F36D009FAA05 /* Debug */, 499 | F2897BA61395F36D009FAA05 /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | }; 503 | /* End XCConfigurationList section */ 504 | }; 505 | rootObject = F2897B611395F36C009FAA05 /* Project object */; 506 | } 507 | -------------------------------------------------------------------------------- /SSHCore/libssh2.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2004-2009, Sara Golemon 2 | * Copyright (c) 2009 by Daniel Stenberg 3 | * Copyright (c) 2010 Simon Josefsson 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, 7 | * with or without modification, are permitted provided 8 | * that the following conditions are met: 9 | * 10 | * Redistributions of source code must retain the above 11 | * copyright notice, this list of conditions and the 12 | * following disclaimer. 13 | * 14 | * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following 16 | * disclaimer in the documentation and/or other materials 17 | * provided with the distribution. 18 | * 19 | * Neither the name of the copyright holder nor the names 20 | * of any other contributors may be used to endorse or 21 | * promote products derived from this software without 22 | * specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 25 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 26 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 27 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 29 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 31 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 34 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 36 | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 37 | * OF SUCH DAMAGE. 38 | */ 39 | 40 | #ifndef LIBSSH2_H 41 | #define LIBSSH2_H 1 42 | 43 | #define LIBSSH2_COPYRIGHT "2004-2010 The libssh2 project and its contributors." 44 | 45 | /* We use underscore instead of dash when appending DEV in dev versions just 46 | to make the BANNER define (used by src/session.c) be a valid SSH 47 | banner. Release versions have no appended strings and may of course not 48 | have dashes either. */ 49 | #define LIBSSH2_VERSION "1.2.7" 50 | 51 | /* The numeric version number is also available "in parts" by using these 52 | defines: */ 53 | #define LIBSSH2_VERSION_MAJOR 1 54 | #define LIBSSH2_VERSION_MINOR 2 55 | #define LIBSSH2_VERSION_PATCH 7 56 | 57 | /* This is the numeric version of the libssh2 version number, meant for easier 58 | parsing and comparions by programs. The LIBSSH2_VERSION_NUM define will 59 | always follow this syntax: 60 | 61 | 0xXXYYZZ 62 | 63 | Where XX, YY and ZZ are the main version, release and patch numbers in 64 | hexadecimal (using 8 bits each). All three numbers are always represented 65 | using two digits. 1.2 would appear as "0x010200" while version 9.11.7 66 | appears as "0x090b07". 67 | 68 | This 6-digit (24 bits) hexadecimal number does not show pre-release number, 69 | and it is always a greater number in a more recent release. It makes 70 | comparisons with greater than and less than work. 71 | */ 72 | #define LIBSSH2_VERSION_NUM 0x010207 73 | 74 | /* 75 | * This is the date and time when the full source package was created. The 76 | * timestamp is not stored in the source code repo, as the timestamp is 77 | * properly set in the tarballs by the maketgz script. 78 | * 79 | * The format of the date should follow this template: 80 | * 81 | * "Mon Feb 12 11:35:33 UTC 2007" 82 | */ 83 | #define LIBSSH2_TIMESTAMP "Tue Aug 17 21:11:33 UTC 2010" 84 | 85 | #ifndef LIBSSH2_VERSION_ONLY 86 | 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | 91 | #include 92 | #include 93 | #include 94 | #include 95 | 96 | /* Allow alternate API prefix from CFLAGS or calling app */ 97 | #ifndef LIBSSH2_API 98 | # ifdef LIBSSH2_WIN32 99 | # ifdef LIBSSH2_LIBRARY 100 | # define LIBSSH2_API __declspec(dllexport) 101 | # else 102 | # define LIBSSH2_API __declspec(dllimport) 103 | # endif /* LIBSSH2_LIBRARY */ 104 | # else /* !LIBSSH2_WIN32 */ 105 | # define LIBSSH2_API 106 | # endif /* LIBSSH2_WIN32 */ 107 | #endif /* LIBSSH2_API */ 108 | 109 | #if defined(LIBSSH2_DARWIN) || (defined(LIBSSH2_WIN32) && \ 110 | !defined(_MSC_VER) && !defined(__MINGW32__)) 111 | # include 112 | #endif 113 | 114 | #if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) 115 | # include 116 | typedef unsigned char uint8_t; 117 | typedef unsigned int uint32_t; 118 | #endif 119 | 120 | #ifdef _MSC_VER 121 | typedef unsigned char uint8_t; 122 | typedef unsigned int uint32_t; 123 | typedef unsigned __int64 libssh2_uint64_t; 124 | typedef __int64 libssh2_int64_t; 125 | # ifndef _SSIZE_T_DEFINED 126 | typedef int ssize_t; 127 | # define _SSIZE_T_DEFINED 128 | #endif 129 | #else 130 | typedef unsigned long long libssh2_uint64_t; 131 | typedef long long libssh2_int64_t; 132 | #endif 133 | 134 | /* Part of every banner, user specified or not */ 135 | #define LIBSSH2_SSH_BANNER "SSH-2.0-libssh2_" LIBSSH2_VERSION 136 | 137 | /* We *could* add a comment here if we so chose */ 138 | #define LIBSSH2_SSH_DEFAULT_BANNER LIBSSH2_SSH_BANNER 139 | #define LIBSSH2_SSH_DEFAULT_BANNER_WITH_CRLF LIBSSH2_SSH_DEFAULT_BANNER "\r\n" 140 | 141 | /* Default generate and safe prime sizes for diffie-hellman-group-exchange-sha1 */ 142 | #define LIBSSH2_DH_GEX_MINGROUP 1024 143 | #define LIBSSH2_DH_GEX_OPTGROUP 1536 144 | #define LIBSSH2_DH_GEX_MAXGROUP 2048 145 | 146 | /* Defaults for pty requests */ 147 | #define LIBSSH2_TERM_WIDTH 80 148 | #define LIBSSH2_TERM_HEIGHT 24 149 | #define LIBSSH2_TERM_WIDTH_PX 0 150 | #define LIBSSH2_TERM_HEIGHT_PX 0 151 | 152 | /* 1/4 second */ 153 | #define LIBSSH2_SOCKET_POLL_UDELAY 250000 154 | /* 0.25 * 120 == 30 seconds */ 155 | #define LIBSSH2_SOCKET_POLL_MAXLOOPS 120 156 | 157 | /* Maximum size to allow a payload to compress to, plays it safe by falling 158 | short of spec limits */ 159 | #define LIBSSH2_PACKET_MAXCOMP 32000 160 | 161 | /* Maximum size to allow a payload to deccompress to, plays it safe by 162 | allowing more than spec requires */ 163 | #define LIBSSH2_PACKET_MAXDECOMP 40000 164 | 165 | /* Maximum size for an inbound compressed payload, plays it safe by 166 | overshooting spec limits */ 167 | #define LIBSSH2_PACKET_MAXPAYLOAD 40000 168 | 169 | /* Malloc callbacks */ 170 | #define LIBSSH2_ALLOC_FUNC(name) void *name(size_t count, void **abstract) 171 | #define LIBSSH2_REALLOC_FUNC(name) void *name(void *ptr, size_t count, \ 172 | void **abstract) 173 | #define LIBSSH2_FREE_FUNC(name) void name(void *ptr, void **abstract) 174 | 175 | typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT 176 | { 177 | char* text; 178 | unsigned int length; 179 | unsigned char echo; 180 | } LIBSSH2_USERAUTH_KBDINT_PROMPT; 181 | 182 | typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE 183 | { 184 | char* text; 185 | unsigned int length; 186 | } LIBSSH2_USERAUTH_KBDINT_RESPONSE; 187 | 188 | /* 'publickey' authentication callback */ 189 | #define LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC(name) \ 190 | int name(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, \ 191 | const unsigned char *data, size_t data_len, void **abstract) 192 | 193 | /* 'keyboard-interactive' authentication callback */ 194 | #define LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(name_) \ 195 | void name_(const char* name, int name_len, const char* instruction, \ 196 | int instruction_len, int num_prompts, \ 197 | const LIBSSH2_USERAUTH_KBDINT_PROMPT* prompts, \ 198 | LIBSSH2_USERAUTH_KBDINT_RESPONSE* responses, void **abstract) 199 | 200 | /* Callbacks for special SSH packets */ 201 | #define LIBSSH2_IGNORE_FUNC(name) \ 202 | void name(LIBSSH2_SESSION *session, const char *message, int message_len, \ 203 | void **abstract) 204 | 205 | #define LIBSSH2_DEBUG_FUNC(name) \ 206 | void name(LIBSSH2_SESSION *session, int always_display, const char *message, \ 207 | int message_len, const char *language, int language_len, \ 208 | void **abstract) 209 | 210 | #define LIBSSH2_DISCONNECT_FUNC(name) \ 211 | void name(LIBSSH2_SESSION *session, int reason, const char *message, \ 212 | int message_len, const char *language, int language_len, \ 213 | void **abstract) 214 | 215 | #define LIBSSH2_PASSWD_CHANGEREQ_FUNC(name) \ 216 | void name(LIBSSH2_SESSION *session, char **newpw, int *newpw_len, \ 217 | void **abstract) 218 | 219 | #define LIBSSH2_MACERROR_FUNC(name) \ 220 | int name(LIBSSH2_SESSION *session, const char *packet, int packet_len, \ 221 | void **abstract) 222 | 223 | #define LIBSSH2_X11_OPEN_FUNC(name) \ 224 | void name(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, \ 225 | const char *shost, int sport, void **abstract) 226 | 227 | #define LIBSSH2_CHANNEL_CLOSE_FUNC(name) \ 228 | void name(LIBSSH2_SESSION *session, void **session_abstract, \ 229 | LIBSSH2_CHANNEL *channel, void **channel_abstract) 230 | 231 | /* libssh2_session_callback_set() constants */ 232 | #define LIBSSH2_CALLBACK_IGNORE 0 233 | #define LIBSSH2_CALLBACK_DEBUG 1 234 | #define LIBSSH2_CALLBACK_DISCONNECT 2 235 | #define LIBSSH2_CALLBACK_MACERROR 3 236 | #define LIBSSH2_CALLBACK_X11 4 237 | 238 | /* libssh2_session_method_pref() constants */ 239 | #define LIBSSH2_METHOD_KEX 0 240 | #define LIBSSH2_METHOD_HOSTKEY 1 241 | #define LIBSSH2_METHOD_CRYPT_CS 2 242 | #define LIBSSH2_METHOD_CRYPT_SC 3 243 | #define LIBSSH2_METHOD_MAC_CS 4 244 | #define LIBSSH2_METHOD_MAC_SC 5 245 | #define LIBSSH2_METHOD_COMP_CS 6 246 | #define LIBSSH2_METHOD_COMP_SC 7 247 | #define LIBSSH2_METHOD_LANG_CS 8 248 | #define LIBSSH2_METHOD_LANG_SC 9 249 | 250 | /* session.flags bits */ 251 | #define LIBSSH2_FLAG_SIGPIPE 0x00000001 252 | 253 | typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION; 254 | typedef struct _LIBSSH2_CHANNEL LIBSSH2_CHANNEL; 255 | typedef struct _LIBSSH2_LISTENER LIBSSH2_LISTENER; 256 | typedef struct _LIBSSH2_KNOWNHOSTS LIBSSH2_KNOWNHOSTS; 257 | typedef struct _LIBSSH2_AGENT LIBSSH2_AGENT; 258 | 259 | typedef struct _LIBSSH2_POLLFD { 260 | unsigned char type; /* LIBSSH2_POLLFD_* below */ 261 | 262 | union { 263 | int socket; /* File descriptors -- examined with system select() call */ 264 | LIBSSH2_CHANNEL *channel; /* Examined by checking internal state */ 265 | LIBSSH2_LISTENER *listener; /* Read polls only -- are inbound 266 | connections waiting to be accepted? */ 267 | } fd; 268 | 269 | unsigned long events; /* Requested Events */ 270 | unsigned long revents; /* Returned Events */ 271 | } LIBSSH2_POLLFD; 272 | 273 | /* Poll FD Descriptor Types */ 274 | #define LIBSSH2_POLLFD_SOCKET 1 275 | #define LIBSSH2_POLLFD_CHANNEL 2 276 | #define LIBSSH2_POLLFD_LISTENER 3 277 | 278 | /* Note: Win32 Doesn't actually have a poll() implementation, so some of these 279 | values are faked with select() data */ 280 | /* Poll FD events/revents -- Match sys/poll.h where possible */ 281 | #define LIBSSH2_POLLFD_POLLIN 0x0001 /* Data available to be read or 282 | connection available -- 283 | All */ 284 | #define LIBSSH2_POLLFD_POLLPRI 0x0002 /* Priority data available to 285 | be read -- Socket only */ 286 | #define LIBSSH2_POLLFD_POLLEXT 0x0002 /* Extended data available to 287 | be read -- Channel only */ 288 | #define LIBSSH2_POLLFD_POLLOUT 0x0004 /* Can may be written -- 289 | Socket/Channel */ 290 | /* revents only */ 291 | #define LIBSSH2_POLLFD_POLLERR 0x0008 /* Error Condition -- Socket */ 292 | #define LIBSSH2_POLLFD_POLLHUP 0x0010 /* HangUp/EOF -- Socket */ 293 | #define LIBSSH2_POLLFD_SESSION_CLOSED 0x0010 /* Session Disconnect */ 294 | #define LIBSSH2_POLLFD_POLLNVAL 0x0020 /* Invalid request -- Socket 295 | Only */ 296 | #define LIBSSH2_POLLFD_POLLEX 0x0040 /* Exception Condition -- 297 | Socket/Win32 */ 298 | #define LIBSSH2_POLLFD_CHANNEL_CLOSED 0x0080 /* Channel Disconnect */ 299 | #define LIBSSH2_POLLFD_LISTENER_CLOSED 0x0080 /* Listener Disconnect */ 300 | 301 | #define HAVE_LIBSSH2_SESSION_BLOCK_DIRECTION 302 | /* Block Direction Types */ 303 | #define LIBSSH2_SESSION_BLOCK_INBOUND 0x0001 304 | #define LIBSSH2_SESSION_BLOCK_OUTBOUND 0x0002 305 | 306 | /* Hash Types */ 307 | #define LIBSSH2_HOSTKEY_HASH_MD5 1 308 | #define LIBSSH2_HOSTKEY_HASH_SHA1 2 309 | 310 | /* Hostkey Types */ 311 | #define LIBSSH2_HOSTKEY_TYPE_UNKNOWN 0 312 | #define LIBSSH2_HOSTKEY_TYPE_RSA 1 313 | #define LIBSSH2_HOSTKEY_TYPE_DSS 2 314 | 315 | /* Disconnect Codes (defined by SSH protocol) */ 316 | #define SSH_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT 1 317 | #define SSH_DISCONNECT_PROTOCOL_ERROR 2 318 | #define SSH_DISCONNECT_KEY_EXCHANGE_FAILED 3 319 | #define SSH_DISCONNECT_RESERVED 4 320 | #define SSH_DISCONNECT_MAC_ERROR 5 321 | #define SSH_DISCONNECT_COMPRESSION_ERROR 6 322 | #define SSH_DISCONNECT_SERVICE_NOT_AVAILABLE 7 323 | #define SSH_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED 8 324 | #define SSH_DISCONNECT_HOST_KEY_NOT_VERIFIABLE 9 325 | #define SSH_DISCONNECT_CONNECTION_LOST 10 326 | #define SSH_DISCONNECT_BY_APPLICATION 11 327 | #define SSH_DISCONNECT_TOO_MANY_CONNECTIONS 12 328 | #define SSH_DISCONNECT_AUTH_CANCELLED_BY_USER 13 329 | #define SSH_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE 14 330 | #define SSH_DISCONNECT_ILLEGAL_USER_NAME 15 331 | 332 | /* Error Codes (defined by libssh2) */ 333 | #define LIBSSH2_ERROR_NONE 0 334 | #define LIBSSH2_ERROR_SOCKET_NONE -1 335 | #define LIBSSH2_ERROR_BANNER_NONE -2 336 | #define LIBSSH2_ERROR_BANNER_SEND -3 337 | #define LIBSSH2_ERROR_INVALID_MAC -4 338 | #define LIBSSH2_ERROR_KEX_FAILURE -5 339 | #define LIBSSH2_ERROR_ALLOC -6 340 | #define LIBSSH2_ERROR_SOCKET_SEND -7 341 | #define LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE -8 342 | #define LIBSSH2_ERROR_TIMEOUT -9 343 | #define LIBSSH2_ERROR_HOSTKEY_INIT -10 344 | #define LIBSSH2_ERROR_HOSTKEY_SIGN -11 345 | #define LIBSSH2_ERROR_DECRYPT -12 346 | #define LIBSSH2_ERROR_SOCKET_DISCONNECT -13 347 | #define LIBSSH2_ERROR_PROTO -14 348 | #define LIBSSH2_ERROR_PASSWORD_EXPIRED -15 349 | #define LIBSSH2_ERROR_FILE -16 350 | #define LIBSSH2_ERROR_METHOD_NONE -17 351 | #define LIBSSH2_ERROR_AUTHENTICATION_FAILED -18 352 | #define LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED LIBSSH2_ERROR_AUTHENTICATION_FAILED 353 | #define LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED -19 354 | #define LIBSSH2_ERROR_CHANNEL_OUTOFORDER -20 355 | #define LIBSSH2_ERROR_CHANNEL_FAILURE -21 356 | #define LIBSSH2_ERROR_CHANNEL_REQUEST_DENIED -22 357 | #define LIBSSH2_ERROR_CHANNEL_UNKNOWN -23 358 | #define LIBSSH2_ERROR_CHANNEL_WINDOW_EXCEEDED -24 359 | #define LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED -25 360 | #define LIBSSH2_ERROR_CHANNEL_CLOSED -26 361 | #define LIBSSH2_ERROR_CHANNEL_EOF_SENT -27 362 | #define LIBSSH2_ERROR_SCP_PROTOCOL -28 363 | #define LIBSSH2_ERROR_ZLIB -29 364 | #define LIBSSH2_ERROR_SOCKET_TIMEOUT -30 365 | #define LIBSSH2_ERROR_SFTP_PROTOCOL -31 366 | #define LIBSSH2_ERROR_REQUEST_DENIED -32 367 | #define LIBSSH2_ERROR_METHOD_NOT_SUPPORTED -33 368 | #define LIBSSH2_ERROR_INVAL -34 369 | #define LIBSSH2_ERROR_INVALID_POLL_TYPE -35 370 | #define LIBSSH2_ERROR_PUBLICKEY_PROTOCOL -36 371 | #define LIBSSH2_ERROR_EAGAIN -37 372 | #define LIBSSH2_ERROR_BUFFER_TOO_SMALL -38 373 | #define LIBSSH2_ERROR_BAD_USE -39 374 | #define LIBSSH2_ERROR_COMPRESS -40 375 | #define LIBSSH2_ERROR_OUT_OF_BOUNDARY -41 376 | #define LIBSSH2_ERROR_AGENT_PROTOCOL -42 377 | 378 | /* Global API */ 379 | #define LIBSSH2_INIT_NO_CRYPTO 0x0001 380 | 381 | /* 382 | * libssh2_init() 383 | * 384 | * Initialize the libssh2 functions. This typically initialize the 385 | * crypto library. It uses a global state, and is not thread safe -- 386 | * you must make sure this function is not called concurrently. 387 | * 388 | * Flags can be: 389 | * 0: Normal initialize 390 | * LIBSSH2_INIT_NO_CRYPTO: Do not initialize the crypto library (ie. 391 | * OPENSSL_add_cipher_algoritms() for OpenSSL 392 | * 393 | * Returns 0 if succeeded, or a negative value for error. 394 | */ 395 | LIBSSH2_API int libssh2_init(int flags); 396 | 397 | /* 398 | * libssh2_exit() 399 | * 400 | * Exit the libssh2 functions and free's all memory used internal. 401 | */ 402 | LIBSSH2_API void libssh2_exit(void); 403 | 404 | /* Session API */ 405 | LIBSSH2_API LIBSSH2_SESSION * 406 | libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)), 407 | LIBSSH2_FREE_FUNC((*my_free)), 408 | LIBSSH2_REALLOC_FUNC((*my_realloc)), void *abstract); 409 | #define libssh2_session_init() libssh2_session_init_ex(NULL, NULL, NULL, NULL) 410 | 411 | LIBSSH2_API void **libssh2_session_abstract(LIBSSH2_SESSION *session); 412 | 413 | LIBSSH2_API void *libssh2_session_callback_set(LIBSSH2_SESSION *session, 414 | int cbtype, void *callback); 415 | LIBSSH2_API int libssh2_banner_set(LIBSSH2_SESSION *session, 416 | const char *banner); 417 | 418 | LIBSSH2_API int libssh2_session_startup(LIBSSH2_SESSION *session, int sock); 419 | LIBSSH2_API int libssh2_session_disconnect_ex(LIBSSH2_SESSION *session, 420 | int reason, 421 | const char *description, 422 | const char *lang); 423 | #define libssh2_session_disconnect(session, description) \ 424 | libssh2_session_disconnect_ex((session), SSH_DISCONNECT_BY_APPLICATION, \ 425 | (description), "") 426 | 427 | LIBSSH2_API int libssh2_session_free(LIBSSH2_SESSION *session); 428 | 429 | LIBSSH2_API const char *libssh2_hostkey_hash(LIBSSH2_SESSION *session, 430 | int hash_type); 431 | 432 | LIBSSH2_API const char *libssh2_session_hostkey(LIBSSH2_SESSION *session, 433 | size_t *len, int *type); 434 | 435 | LIBSSH2_API int libssh2_session_method_pref(LIBSSH2_SESSION *session, 436 | int method_type, 437 | const char *prefs); 438 | LIBSSH2_API const char *libssh2_session_methods(LIBSSH2_SESSION *session, 439 | int method_type); 440 | LIBSSH2_API int libssh2_session_last_error(LIBSSH2_SESSION *session, 441 | char **errmsg, 442 | int *errmsg_len, int want_buf); 443 | LIBSSH2_API int libssh2_session_last_errno(LIBSSH2_SESSION *session); 444 | LIBSSH2_API int libssh2_session_block_directions(LIBSSH2_SESSION *session); 445 | 446 | LIBSSH2_API int libssh2_session_flag(LIBSSH2_SESSION *session, int flag, 447 | int value); 448 | 449 | /* Userauth API */ 450 | LIBSSH2_API char *libssh2_userauth_list(LIBSSH2_SESSION *session, 451 | const char *username, 452 | unsigned int username_len); 453 | LIBSSH2_API int libssh2_userauth_authenticated(LIBSSH2_SESSION *session); 454 | 455 | LIBSSH2_API int libssh2_userauth_password_ex(LIBSSH2_SESSION *session, 456 | const char *username, 457 | unsigned int username_len, 458 | const char *password, 459 | unsigned int password_len, 460 | LIBSSH2_PASSWD_CHANGEREQ_FUNC((*passwd_change_cb))); 461 | 462 | #define libssh2_userauth_password(session, username, password) \ 463 | libssh2_userauth_password_ex((session), (username), strlen(username), \ 464 | (password), strlen(password), NULL) 465 | 466 | LIBSSH2_API int 467 | libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session, 468 | const char *username, 469 | unsigned int username_len, 470 | const char *publickey, 471 | const char *privatekey, 472 | const char *passphrase); 473 | 474 | #define libssh2_userauth_publickey_fromfile(session, username, publickey, \ 475 | privatekey, passphrase) \ 476 | libssh2_userauth_publickey_fromfile_ex((session), (username), \ 477 | strlen(username), (publickey), \ 478 | (privatekey), (passphrase)) 479 | 480 | LIBSSH2_API int 481 | libssh2_userauth_publickey(LIBSSH2_SESSION *session, 482 | const char *username, 483 | const unsigned char *pubkeydata, 484 | size_t pubkeydata_len, 485 | LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*sign_callback)), 486 | void **abstract); 487 | 488 | LIBSSH2_API int 489 | libssh2_userauth_hostbased_fromfile_ex(LIBSSH2_SESSION *session, 490 | const char *username, 491 | unsigned int username_len, 492 | const char *publickey, 493 | const char *privatekey, 494 | const char *passphrase, 495 | const char *hostname, 496 | unsigned int hostname_len, 497 | const char *local_username, 498 | unsigned int local_username_len); 499 | 500 | #define libssh2_userauth_hostbased_fromfile(session, username, publickey, \ 501 | privatekey, passphrase, hostname) \ 502 | libssh2_userauth_hostbased_fromfile_ex((session), (username), \ 503 | strlen(username), (publickey), \ 504 | (privatekey), (passphrase), \ 505 | (hostname), strlen(hostname), \ 506 | (username), strlen(username)) 507 | 508 | /* 509 | * response_callback is provided with filled by library prompts array, 510 | * but client must allocate and fill individual responses. Responses 511 | * array is already allocated. Responses data will be freed by libssh2 512 | * after callback return, but before subsequent callback invokation. 513 | */ 514 | LIBSSH2_API int 515 | libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION* session, 516 | const char *username, 517 | unsigned int username_len, 518 | LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*response_callback))); 519 | 520 | #define libssh2_userauth_keyboard_interactive(session, username, \ 521 | response_callback) \ 522 | libssh2_userauth_keyboard_interactive_ex((session), (username), \ 523 | strlen(username), (response_callback)) 524 | 525 | LIBSSH2_API int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds, 526 | long timeout); 527 | 528 | /* Channel API */ 529 | #define LIBSSH2_CHANNEL_WINDOW_DEFAULT 65536 530 | #define LIBSSH2_CHANNEL_PACKET_DEFAULT 32768 531 | #define LIBSSH2_CHANNEL_MINADJUST 1024 532 | 533 | /* Extended Data Handling */ 534 | #define LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL 0 535 | #define LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE 1 536 | #define LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE 2 537 | 538 | #define SSH_EXTENDED_DATA_STDERR 1 539 | 540 | /* Returned by any function that would block during a read/write opperation */ 541 | #define LIBSSH2CHANNEL_EAGAIN LIBSSH2_ERROR_EAGAIN 542 | 543 | LIBSSH2_API LIBSSH2_CHANNEL * 544 | libssh2_channel_open_ex(LIBSSH2_SESSION *session, const char *channel_type, 545 | unsigned int channel_type_len, 546 | unsigned int window_size, unsigned int packet_size, 547 | const char *message, unsigned int message_len); 548 | 549 | #define libssh2_channel_open_session(session) \ 550 | libssh2_channel_open_ex((session), "session", sizeof("session") - 1, \ 551 | LIBSSH2_CHANNEL_WINDOW_DEFAULT, \ 552 | LIBSSH2_CHANNEL_PACKET_DEFAULT, NULL, 0) 553 | 554 | LIBSSH2_API LIBSSH2_CHANNEL * 555 | libssh2_channel_direct_tcpip_ex(LIBSSH2_SESSION *session, const char *host, 556 | int port, const char *shost, int sport); 557 | #define libssh2_channel_direct_tcpip(session, host, port) \ 558 | libssh2_channel_direct_tcpip_ex((session), (host), (port), "127.0.0.1", 22) 559 | 560 | LIBSSH2_API LIBSSH2_LISTENER * 561 | libssh2_channel_forward_listen_ex(LIBSSH2_SESSION *session, const char *host, 562 | int port, int *bound_port, int queue_maxsize); 563 | #define libssh2_channel_forward_listen(session, port) \ 564 | libssh2_channel_forward_listen_ex((session), NULL, (port), NULL, 16) 565 | 566 | LIBSSH2_API int libssh2_channel_forward_cancel(LIBSSH2_LISTENER *listener); 567 | 568 | LIBSSH2_API LIBSSH2_CHANNEL * 569 | libssh2_channel_forward_accept(LIBSSH2_LISTENER *listener); 570 | 571 | LIBSSH2_API int libssh2_channel_setenv_ex(LIBSSH2_CHANNEL *channel, 572 | const char *varname, 573 | unsigned int varname_len, 574 | const char *value, 575 | unsigned int value_len); 576 | 577 | #define libssh2_channel_setenv(channel, varname, value) \ 578 | libssh2_channel_setenv_ex((channel), (varname), strlen(varname), (value), \ 579 | strlen(value)) 580 | 581 | LIBSSH2_API int libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel, 582 | const char *term, 583 | unsigned int term_len, 584 | const char *modes, 585 | unsigned int modes_len, 586 | int width, int height, 587 | int width_px, int height_px); 588 | #define libssh2_channel_request_pty(channel, term) \ 589 | libssh2_channel_request_pty_ex((channel), (term), strlen(term), NULL, 0, \ 590 | LIBSSH2_TERM_WIDTH, LIBSSH2_TERM_HEIGHT, \ 591 | LIBSSH2_TERM_WIDTH_PX, LIBSSH2_TERM_HEIGHT_PX) 592 | 593 | LIBSSH2_API int libssh2_channel_request_pty_size_ex(LIBSSH2_CHANNEL *channel, 594 | int width, int height, 595 | int width_px, 596 | int height_px); 597 | #define libssh2_channel_request_pty_size(channel, width, height) \ 598 | libssh2_channel_request_pty_size_ex( (channel), (width), (height), 0, 0) 599 | 600 | LIBSSH2_API int libssh2_channel_x11_req_ex(LIBSSH2_CHANNEL *channel, 601 | int single_connection, 602 | const char *auth_proto, 603 | const char *auth_cookie, 604 | int screen_number); 605 | #define libssh2_channel_x11_req(channel, screen_number) \ 606 | libssh2_channel_x11_req_ex((channel), 0, NULL, NULL, (screen_number)) 607 | 608 | LIBSSH2_API int libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel, 609 | const char *request, 610 | unsigned int request_len, 611 | const char *message, 612 | unsigned int message_len); 613 | #define libssh2_channel_shell(channel) \ 614 | libssh2_channel_process_startup((channel), "shell", sizeof("shell") - 1, \ 615 | NULL, 0) 616 | #define libssh2_channel_exec(channel, command) \ 617 | libssh2_channel_process_startup((channel), "exec", sizeof("exec") - 1, \ 618 | (command), strlen(command)) 619 | #define libssh2_channel_subsystem(channel, subsystem) \ 620 | libssh2_channel_process_startup((channel), "subsystem", \ 621 | sizeof("subsystem") - 1, (subsystem), \ 622 | strlen(subsystem)) 623 | 624 | LIBSSH2_API ssize_t libssh2_channel_read_ex(LIBSSH2_CHANNEL *channel, 625 | int stream_id, char *buf, 626 | size_t buflen); 627 | #define libssh2_channel_read(channel, buf, buflen) \ 628 | libssh2_channel_read_ex((channel), 0, (buf), (buflen)) 629 | #define libssh2_channel_read_stderr(channel, buf, buflen) \ 630 | libssh2_channel_read_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen)) 631 | 632 | LIBSSH2_API int libssh2_poll_channel_read(LIBSSH2_CHANNEL *channel, 633 | int extended); 634 | 635 | LIBSSH2_API unsigned long 636 | libssh2_channel_window_read_ex(LIBSSH2_CHANNEL *channel, 637 | unsigned long *read_avail, 638 | unsigned long *window_size_initial); 639 | #define libssh2_channel_window_read(channel) \ 640 | libssh2_channel_window_read_ex((channel), NULL, NULL) 641 | 642 | /* libssh2_channel_receive_window_adjust is DEPRECATED, do not use! */ 643 | LIBSSH2_API unsigned long 644 | libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL *channel, 645 | unsigned long adjustment, 646 | unsigned char force); 647 | 648 | LIBSSH2_API int 649 | libssh2_channel_receive_window_adjust2(LIBSSH2_CHANNEL *channel, 650 | unsigned long adjustment, 651 | unsigned char force, 652 | unsigned int *storewindow); 653 | 654 | LIBSSH2_API ssize_t libssh2_channel_write_ex(LIBSSH2_CHANNEL *channel, 655 | int stream_id, const char *buf, 656 | size_t buflen); 657 | 658 | #define libssh2_channel_write(channel, buf, buflen) \ 659 | libssh2_channel_write_ex((channel), 0, (buf), (buflen)) 660 | #define libssh2_channel_write_stderr(channel, buf, buflen) \ 661 | libssh2_channel_write_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen)) 662 | 663 | LIBSSH2_API unsigned long 664 | libssh2_channel_window_write_ex(LIBSSH2_CHANNEL *channel, 665 | unsigned long *window_size_initial); 666 | #define libssh2_channel_window_write(channel) \ 667 | libssh2_channel_window_write_ex((channel), NULL) 668 | 669 | LIBSSH2_API void libssh2_session_set_blocking(LIBSSH2_SESSION* session, 670 | int blocking); 671 | LIBSSH2_API int libssh2_session_get_blocking(LIBSSH2_SESSION* session); 672 | 673 | LIBSSH2_API void libssh2_channel_set_blocking(LIBSSH2_CHANNEL *channel, 674 | int blocking); 675 | 676 | /* libssh2_channel_handle_extended_data is DEPRECATED, do not use! */ 677 | LIBSSH2_API void libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel, 678 | int ignore_mode); 679 | LIBSSH2_API int libssh2_channel_handle_extended_data2(LIBSSH2_CHANNEL *channel, 680 | int ignore_mode); 681 | 682 | /* libssh2_channel_ignore_extended_data() is defined below for BC with version 683 | * 0.1 684 | * 685 | * Future uses should use libssh2_channel_handle_extended_data() directly if 686 | * LIBSSH2_CHANNEL_EXTENDED_DATA_MERGE is passed, extended data will be read 687 | * (FIFO) from the standard data channel 688 | */ 689 | /* DEPRECATED */ 690 | #define libssh2_channel_ignore_extended_data(channel, ignore) \ 691 | libssh2_channel_handle_extended_data((channel), \ 692 | (ignore) ? \ 693 | LIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE : \ 694 | LIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL ) 695 | 696 | #define LIBSSH2_CHANNEL_FLUSH_EXTENDED_DATA -1 697 | #define LIBSSH2_CHANNEL_FLUSH_ALL -2 698 | LIBSSH2_API int libssh2_channel_flush_ex(LIBSSH2_CHANNEL *channel, 699 | int streamid); 700 | #define libssh2_channel_flush(channel) libssh2_channel_flush_ex((channel), 0) 701 | #define libssh2_channel_flush_stderr(channel) \ 702 | libssh2_channel_flush_ex((channel), SSH_EXTENDED_DATA_STDERR) 703 | 704 | LIBSSH2_API int libssh2_channel_get_exit_status(LIBSSH2_CHANNEL* channel); 705 | LIBSSH2_API int libssh2_channel_send_eof(LIBSSH2_CHANNEL *channel); 706 | LIBSSH2_API int libssh2_channel_eof(LIBSSH2_CHANNEL *channel); 707 | LIBSSH2_API int libssh2_channel_wait_eof(LIBSSH2_CHANNEL *channel); 708 | LIBSSH2_API int libssh2_channel_close(LIBSSH2_CHANNEL *channel); 709 | LIBSSH2_API int libssh2_channel_wait_closed(LIBSSH2_CHANNEL *channel); 710 | LIBSSH2_API int libssh2_channel_free(LIBSSH2_CHANNEL *channel); 711 | 712 | LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session, 713 | const char *path, 714 | struct stat *sb); 715 | LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session, 716 | const char *path, int mode, 717 | size_t size, long mtime, 718 | long atime); 719 | LIBSSH2_API LIBSSH2_CHANNEL * 720 | libssh2_scp_send64(LIBSSH2_SESSION *session, const char *path, int mode, 721 | libssh2_int64_t size, time_t mtime, time_t atime); 722 | 723 | #define libssh2_scp_send(session, path, mode, size) \ 724 | libssh2_scp_send_ex((session), (path), (mode), (size), 0, 0) 725 | 726 | LIBSSH2_API int libssh2_base64_decode(LIBSSH2_SESSION *session, char **dest, 727 | unsigned int *dest_len, 728 | const char *src, unsigned int src_len); 729 | 730 | LIBSSH2_API 731 | const char *libssh2_version(int req_version_num); 732 | 733 | #define HAVE_LIBSSH2_KNOWNHOST_API 0x010101 /* since 1.1.1 */ 734 | #define HAVE_LIBSSH2_VERSION_API 0x010100 /* libssh2_version since 1.1 */ 735 | 736 | struct libssh2_knownhost { 737 | unsigned int magic; /* magic stored by the library */ 738 | void *node; /* handle to the internal representation of this host */ 739 | char *name; /* this is NULL if no plain text host name exists */ 740 | char *key; /* key in base64/printable format */ 741 | int typemask; 742 | }; 743 | 744 | /* 745 | * libssh2_knownhost_init 746 | * 747 | * Init a collection of known hosts. Returns the pointer to a collection. 748 | * 749 | */ 750 | LIBSSH2_API LIBSSH2_KNOWNHOSTS * 751 | libssh2_knownhost_init(LIBSSH2_SESSION *session); 752 | 753 | /* 754 | * libssh2_knownhost_add 755 | * 756 | * Add a host and its associated key to the collection of known hosts. 757 | * 758 | * The 'type' argument specifies on what format the given host and keys are: 759 | * 760 | * plain - ascii "hostname.domain.tld" 761 | * sha1 - SHA1( ) base64-encoded! 762 | * custom - another hash 763 | * 764 | * If 'sha1' is selected as type, the salt must be provided to the salt 765 | * argument. This too base64 encoded. 766 | * 767 | * The SHA-1 hash is what OpenSSH can be told to use in known_hosts files. If 768 | * a custom type is used, salt is ignored and you must provide the host 769 | * pre-hashed when checking for it in the libssh2_knownhost_check() function. 770 | * 771 | * The keylen parameter may be omitted (zero) if the key is provided as a 772 | * NULL-terminated base64-encoded string. 773 | */ 774 | 775 | /* host format (2 bits) */ 776 | #define LIBSSH2_KNOWNHOST_TYPE_MASK 0xffff 777 | #define LIBSSH2_KNOWNHOST_TYPE_PLAIN 1 778 | #define LIBSSH2_KNOWNHOST_TYPE_SHA1 2 /* always base64 encoded */ 779 | #define LIBSSH2_KNOWNHOST_TYPE_CUSTOM 3 780 | 781 | /* key format (2 bits) */ 782 | #define LIBSSH2_KNOWNHOST_KEYENC_MASK (3<<16) 783 | #define LIBSSH2_KNOWNHOST_KEYENC_RAW (1<<16) 784 | #define LIBSSH2_KNOWNHOST_KEYENC_BASE64 (2<<16) 785 | 786 | /* type of key (2 bits) */ 787 | #define LIBSSH2_KNOWNHOST_KEY_MASK (3<<18) 788 | #define LIBSSH2_KNOWNHOST_KEY_SHIFT 18 789 | #define LIBSSH2_KNOWNHOST_KEY_RSA1 (1<<18) 790 | #define LIBSSH2_KNOWNHOST_KEY_SSHRSA (2<<18) 791 | #define LIBSSH2_KNOWNHOST_KEY_SSHDSS (3<<18) 792 | 793 | LIBSSH2_API int 794 | libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts, 795 | const char *host, 796 | const char *salt, 797 | const char *key, size_t keylen, int typemask, 798 | struct libssh2_knownhost **store); 799 | 800 | /* 801 | * libssh2_knownhost_addc 802 | * 803 | * Add a host and its associated key to the collection of known hosts. 804 | * 805 | * Takes a comment argument that may be NULL. A NULL comment indicates 806 | * there is no comment and the entry will end directly after the key 807 | * when written out to a file. An empty string "" comment will indicate an 808 | * empty comment which will cause a single space to be written after the key. 809 | * 810 | * The 'type' argument specifies on what format the given host and keys are: 811 | * 812 | * plain - ascii "hostname.domain.tld" 813 | * sha1 - SHA1( ) base64-encoded! 814 | * custom - another hash 815 | * 816 | * If 'sha1' is selected as type, the salt must be provided to the salt 817 | * argument. This too base64 encoded. 818 | * 819 | * The SHA-1 hash is what OpenSSH can be told to use in known_hosts files. If 820 | * a custom type is used, salt is ignored and you must provide the host 821 | * pre-hashed when checking for it in the libssh2_knownhost_check() function. 822 | * 823 | * The keylen parameter may be omitted (zero) if the key is provided as a 824 | * NULL-terminated base64-encoded string. 825 | */ 826 | 827 | LIBSSH2_API int 828 | libssh2_knownhost_addc(LIBSSH2_KNOWNHOSTS *hosts, 829 | const char *host, 830 | const char *salt, 831 | const char *key, size_t keylen, 832 | const char *comment, size_t commentlen, int typemask, 833 | struct libssh2_knownhost **store); 834 | 835 | /* 836 | * libssh2_knownhost_check 837 | * 838 | * Check a host and its associated key against the collection of known hosts. 839 | * 840 | * The type is the type/format of the given host name. 841 | * 842 | * plain - ascii "hostname.domain.tld" 843 | * custom - prehashed base64 encoded. Note that this cannot use any salts. 844 | * 845 | * 846 | * 'knownhost' may be set to NULL if you don't care about that info. 847 | * 848 | * Returns: 849 | * 850 | * LIBSSH2_KNOWNHOST_CHECK_* values, see below 851 | * 852 | */ 853 | 854 | #define LIBSSH2_KNOWNHOST_CHECK_MATCH 0 855 | #define LIBSSH2_KNOWNHOST_CHECK_MISMATCH 1 856 | #define LIBSSH2_KNOWNHOST_CHECK_NOTFOUND 2 857 | #define LIBSSH2_KNOWNHOST_CHECK_FAILURE 3 858 | 859 | LIBSSH2_API int 860 | libssh2_knownhost_check(LIBSSH2_KNOWNHOSTS *hosts, 861 | const char *host, const char *key, size_t keylen, 862 | int typemask, 863 | struct libssh2_knownhost **knownhost); 864 | 865 | /* this function is identital to the above one, but also takes a port 866 | argument that allows libssh2 to do a better check */ 867 | LIBSSH2_API int 868 | libssh2_knownhost_checkp(LIBSSH2_KNOWNHOSTS *hosts, 869 | const char *host, int port, 870 | const char *key, size_t keylen, 871 | int typemask, 872 | struct libssh2_knownhost **knownhost); 873 | 874 | /* 875 | * libssh2_knownhost_del 876 | * 877 | * Remove a host from the collection of known hosts. The 'entry' struct is 878 | * retrieved by a call to libssh2_knownhost_check(). 879 | * 880 | */ 881 | LIBSSH2_API int 882 | libssh2_knownhost_del(LIBSSH2_KNOWNHOSTS *hosts, 883 | struct libssh2_knownhost *entry); 884 | 885 | /* 886 | * libssh2_knownhost_free 887 | * 888 | * Free an entire collection of known hosts. 889 | * 890 | */ 891 | LIBSSH2_API void 892 | libssh2_knownhost_free(LIBSSH2_KNOWNHOSTS *hosts); 893 | 894 | /* 895 | * libssh2_knownhost_readline() 896 | * 897 | * Pass in a line of a file of 'type'. It makes libssh2 read this line. 898 | * 899 | * LIBSSH2_KNOWNHOST_FILE_OPENSSH is the only supported type. 900 | * 901 | */ 902 | LIBSSH2_API int 903 | libssh2_knownhost_readline(LIBSSH2_KNOWNHOSTS *hosts, 904 | const char *line, size_t len, int type); 905 | 906 | /* 907 | * libssh2_knownhost_readfile 908 | * 909 | * Add hosts+key pairs from a given file. 910 | * 911 | * Returns a negative value for error or number of successfully added hosts. 912 | * 913 | * This implementation currently only knows one 'type' (openssh), all others 914 | * are reserved for future use. 915 | */ 916 | 917 | #define LIBSSH2_KNOWNHOST_FILE_OPENSSH 1 918 | 919 | LIBSSH2_API int 920 | libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts, 921 | const char *filename, int type); 922 | 923 | /* 924 | * libssh2_knownhost_writeline() 925 | * 926 | * Ask libssh2 to convert a known host to an output line for storage. 927 | * 928 | * Note that this function returns LIBSSH2_ERROR_BUFFER_TOO_SMALL if the given 929 | * output buffer is too small to hold the desired output. 930 | * 931 | * This implementation currently only knows one 'type' (openssh), all others 932 | * are reserved for future use. 933 | * 934 | */ 935 | LIBSSH2_API int 936 | libssh2_knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts, 937 | struct libssh2_knownhost *known, 938 | char *buffer, size_t buflen, 939 | size_t *outlen, /* the amount of written data */ 940 | int type); 941 | 942 | /* 943 | * libssh2_knownhost_writefile 944 | * 945 | * Write hosts+key pairs to a given file. 946 | * 947 | * This implementation currently only knows one 'type' (openssh), all others 948 | * are reserved for future use. 949 | */ 950 | 951 | LIBSSH2_API int 952 | libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts, 953 | const char *filename, int type); 954 | 955 | /* 956 | * libssh2_knownhost_get() 957 | * 958 | * Traverse the internal list of known hosts. Pass NULL to 'prev' to get 959 | * the first one. Or pass a poiner to the previously returned one to get the 960 | * next. 961 | * 962 | * Returns: 963 | * 0 if a fine host was stored in 'store' 964 | * 1 if end of hosts 965 | * [negative] on errors 966 | */ 967 | LIBSSH2_API int 968 | libssh2_knownhost_get(LIBSSH2_KNOWNHOSTS *hosts, 969 | struct libssh2_knownhost **store, 970 | struct libssh2_knownhost *prev); 971 | 972 | #define HAVE_LIBSSH2_AGENT_API 0x010202 /* since 1.2.2 */ 973 | 974 | struct libssh2_agent_publickey { 975 | unsigned int magic; /* magic stored by the library */ 976 | void *node; /* handle to the internal representation of key */ 977 | unsigned char *blob; /* public key blob */ 978 | size_t blob_len; /* length of the public key blob */ 979 | char *comment; /* comment in printable format */ 980 | }; 981 | 982 | /* 983 | * libssh2_agent_init 984 | * 985 | * Init an ssh-agent handle. Returns the pointer to the handle. 986 | * 987 | */ 988 | LIBSSH2_API LIBSSH2_AGENT * 989 | libssh2_agent_init(LIBSSH2_SESSION *session); 990 | 991 | /* 992 | * libssh2_agent_connect() 993 | * 994 | * Connect to an ssh-agent. 995 | * 996 | * Returns 0 if succeeded, or a negative value for error. 997 | */ 998 | LIBSSH2_API int 999 | libssh2_agent_connect(LIBSSH2_AGENT *agent); 1000 | 1001 | /* 1002 | * libssh2_agent_list_identities() 1003 | * 1004 | * Request an ssh-agent to list identities. 1005 | * 1006 | * Returns 0 if succeeded, or a negative value for error. 1007 | */ 1008 | LIBSSH2_API int 1009 | libssh2_agent_list_identities(LIBSSH2_AGENT *agent); 1010 | 1011 | /* 1012 | * libssh2_agent_get_identity() 1013 | * 1014 | * Traverse the internal list of public keys. Pass NULL to 'prev' to get 1015 | * the first one. Or pass a poiner to the previously returned one to get the 1016 | * next. 1017 | * 1018 | * Returns: 1019 | * 0 if a fine public key was stored in 'store' 1020 | * 1 if end of public keys 1021 | * [negative] on errors 1022 | */ 1023 | LIBSSH2_API int 1024 | libssh2_agent_get_identity(LIBSSH2_AGENT *agent, 1025 | struct libssh2_agent_publickey **store, 1026 | struct libssh2_agent_publickey *prev); 1027 | 1028 | /* 1029 | * libssh2_agent_userauth() 1030 | * 1031 | * Do publickey user authentication with the help of ssh-agent. 1032 | * 1033 | * Returns 0 if succeeded, or a negative value for error. 1034 | */ 1035 | LIBSSH2_API int 1036 | libssh2_agent_userauth(LIBSSH2_AGENT *agent, 1037 | const char *username, 1038 | struct libssh2_agent_publickey *identity); 1039 | 1040 | /* 1041 | * libssh2_agent_disconnect() 1042 | * 1043 | * Close a connection to an ssh-agent. 1044 | * 1045 | * Returns 0 if succeeded, or a negative value for error. 1046 | */ 1047 | LIBSSH2_API int 1048 | libssh2_agent_disconnect(LIBSSH2_AGENT *agent); 1049 | 1050 | /* 1051 | * libssh2_agent_free() 1052 | * 1053 | * Free an ssh-agent handle. This function also frees the internal 1054 | * collection of public keys. 1055 | */ 1056 | LIBSSH2_API void 1057 | libssh2_agent_free(LIBSSH2_AGENT *agent); 1058 | 1059 | 1060 | /* 1061 | * libssh2_keepalive_config() 1062 | * 1063 | * Set how often keepalive messages should be sent. WANT_REPLY 1064 | * indicates whether the keepalive messages should request a response 1065 | * from the server. INTERVAL is number of seconds that can pass 1066 | * without any I/O, use 0 (the default) to disable keepalives. To 1067 | * avoid some busy-loop corner-cases, if you specify an interval of 1 1068 | * it will be treated as 2. 1069 | * 1070 | * Note that non-blocking applications are responsible for sending the 1071 | * keepalive messages using libssh2_keepalive_send(). 1072 | */ 1073 | LIBSSH2_API void libssh2_keepalive_config (LIBSSH2_SESSION *session, 1074 | int want_reply, 1075 | unsigned interval); 1076 | 1077 | /* 1078 | * libssh2_keepalive_send() 1079 | * 1080 | * Send a keepalive message if needed. SECONDS_TO_NEXT indicates how 1081 | * many seconds you can sleep after this call before you need to call 1082 | * it again. Returns 0 on success, or LIBSSH2_ERROR_SOCKET_SEND on 1083 | * I/O errors. 1084 | */ 1085 | LIBSSH2_API int libssh2_keepalive_send (LIBSSH2_SESSION *session, 1086 | int *seconds_to_next); 1087 | 1088 | /* NOTE NOTE NOTE 1089 | libssh2_trace() has no function in builds that aren't built with debug 1090 | enabled 1091 | */ 1092 | LIBSSH2_API int libssh2_trace(LIBSSH2_SESSION *session, int bitmask); 1093 | #define LIBSSH2_TRACE_TRANS (1<<1) 1094 | #define LIBSSH2_TRACE_KEX (1<<2) 1095 | #define LIBSSH2_TRACE_AUTH (1<<3) 1096 | #define LIBSSH2_TRACE_CONN (1<<4) 1097 | #define LIBSSH2_TRACE_SCP (1<<5) 1098 | #define LIBSSH2_TRACE_SFTP (1<<6) 1099 | #define LIBSSH2_TRACE_ERROR (1<<7) 1100 | #define LIBSSH2_TRACE_PUBLICKEY (1<<8) 1101 | #define LIBSSH2_TRACE_SOCKET (1<<9) 1102 | 1103 | typedef void (*libssh2_trace_handler_func)(LIBSSH2_SESSION*, 1104 | void*, 1105 | const char *, 1106 | size_t); 1107 | LIBSSH2_API int libssh2_trace_sethandler(LIBSSH2_SESSION *session, 1108 | void* context, 1109 | libssh2_trace_handler_func callback); 1110 | 1111 | #ifdef __cplusplus 1112 | } /* extern "C" */ 1113 | #endif 1114 | 1115 | #endif /* LIBSSH2_VERSION_ONLY */ 1116 | 1117 | #endif /* LIBSSH2_H */ 1118 | --------------------------------------------------------------------------------