     func authenticate(username: String, privateKey: String, publicKey: String, passphrase: String?) throws {
         let code = libssh2_userauth_publickey_fromfile_ex(cSession,
                                                           username,
-                                                          UInt32(username.characters.count),
+                                                          UInt32(username.count),
                                                           publicKey,
                                                           privateKey,
                                                           passphrase)

    func authenticate(username: String, password: String) throws {
        let code = libssh2_userauth_password_ex(cSession,
                                                username,
                                                UInt32(username.characters.count),
                                                password,
                                                UInt32(password.characters.count),
                                                nil)
        try LibSSH2Error.check(code: code)
    }

    init(rawSession: RawSession) throws {
        guard let cChannel = libssh2_channel_open_ex(rawSession.cSession,
                                                     RawChannel.session,
                                                     UInt32(RawChannel.session.count),
                                                     RawChannel.windowDefault,
                                                     RawChannel.packetDefault, nil, 0) else {
                                                        throw LibSSH2Error.initializationError
