活动介绍
file-type

SHA-1算法C语言实现详解

版权申诉

RAR文件

548KB | 更新于2024-10-20 | 47 浏览量 | 0 下载量 举报 收藏
download 限时特惠:#14.90
SHA-1(Secure Hash Algorithm 1,安全散列算法1)是一种密码散列函数,它将任意长度的数据映射为一个160位的散列值(哈希值),这个值通常表示为一个40位的十六进制字符串。SHA-1是由美国国家安全局(NSA)设计,并由美国国家标准与技术研究院(NIST)发布为联邦数据处理标准(FIPS)。SHA-1是SHA-0的后继者,于1993年作为一个美国联邦信息处理标准发布,旨在确保数据的完整性和安全。虽然SHA-1现在已被认为不安全,并已被更安全的算法如SHA-2和SHA-3所取代,但它在历史上对数据安全领域有着重要的影响。 在C语言中实现SHA-1算法主要涉及以下几个步骤: 1. 数据填充:原始数据根据长度被填充,使得填充后的数据长度为512的倍数,填充的内容包括一个1后面跟随多个0,最后加上一个64位的二进制表示的原始数据长度。 2. 初始化缓冲区:设置初始的哈希值,这些值是SHA-1算法定义的常量,通常是一系列的十六进制数。 3. 数据处理:将填充后的数据分成512位的块,每个块再分成16个32位的字,然后通过一系列的位运算和函数变换来更新缓冲区中的哈希值。 4. 输出结果:完成所有数据块的处理后,得到的最终缓冲区中的值即为原始数据的SHA-1散列值。 SHA-1算法的C语言实现涉及到位操作、循环结构、数组处理等编程基础知识。程序员需要对C语言有深入的理解,同时还需要对SHA-1算法的工作原理有一定的了解,这样才能正确地编写出该算法的代码。 在具体编码过程中,可能会用到一些优化技巧来提高处理速度,比如预计算一些常数表或者使用特殊的位操作技巧。由于SHA-1已经被发现存在安全隐患,实际应用中建议使用更安全的哈希算法,如SHA-256。 该压缩包子文件的文件名称列表中的"Debug"可能暗示着这个C语言实现的SHA-1算法代码是一个调试版本。调试版本的代码通常会包含额外的调试信息,例如变量值、内存地址等,以便开发者进行错误检测和性能分析。此外,可能还会有相应的调试符号,便于使用调试工具进行单步执行、设置断点等操作。 在开发SHA-1算法的C语言实现时,开发者需要对算法的每个细节了如指掌,包括其数据结构、处理逻辑以及安全性评估,才能确保最终的代码既安全又高效。而掌握SHA-1算法的实现对于理解其他更复杂的加密算法也有极大的帮助,比如SHA-2和SHA-3系列算法。

相关推荐

filetype

我把日志级别改成了debug,首先权限,命令都是无问题,权限给的最高,命令我手动ssh登录控制台都可正常显示,也不会报错,但是这个程序命令执行在交换机后台日志看只正确了执行quit这条命令,其余都未执行,程序日志如下:2025-07-15 14:21:27,593 - DEBUG - read_channel: 2025-07-15 14:21:29,594 - DEBUG - read_channel: 2025-07-15 14:21:29,594 - DEBUG - write_channel: b'quit\n' 2025-07-15 14:21:29,594 - DEBUG - EOF in transport thread 2025-07-15 14:21:29,595 - INFO - 172.17.201.28 不是已知汇聚交换机,作为最终设备 2025-07-15 14:21:29,608 - DEBUG - starting thread (client mode): 0x7a64f2f0 2025-07-15 14:21:29,608 - DEBUG - Local version/idstring: SSH-2.0-paramiko_3.5.1 2025-07-15 14:21:29,609 - DEBUG - Remote version/idstring: SSH-1.99-Comware-5.20 2025-07-15 14:21:29,609 - INFO - Connected (version 1.99, client Comware-5.20) 2025-07-15 14:21:29,631 - DEBUG - === Key exchange possibilities === 2025-07-15 14:21:29,631 - DEBUG - kex algos: diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1, diffie-hellman-group1-sha1 2025-07-15 14:21:29,631 - DEBUG - server key: ssh-rsa 2025-07-15 14:21:29,631 - DEBUG - client encrypt: aes128-cbc, 3des-cbc, des-cbc 2025-07-15 14:21:29,631 - DEBUG - server encrypt: aes128-cbc, 3des-cbc, des-cbc 2025-07-15 14:21:29,631 - DEBUG - client mac: hmac-sha1, hmac-sha1-96, hmac-md5, hmac-md5-96 2025-07-15 14:21:29,631 - DEBUG - server mac: hmac-sha1, hmac-sha1-96, hmac-md5, hmac-md5-96 2025-07-15 14:21:29,631 - DEBUG - client compress: none 2025-07-15 14:21:29,631 - DEBUG - server compress: none 2025-07-15 14:21:29,631 - DEBUG - client lang: <none> 2025-07-15 14:21:29,631 - DEBUG - server lang: <none> 2025-07-15 14:21:29,631 - DEBUG - kex follows: False 2025-07-15 14:21:29,631 - DEBUG - === Key exchange agreements === 2025-07-15 14:21:29,631 - DEBUG - Kex: diffie-hellman-group-exchange-sha1 2025-07-15 14:21:29,631 - DEBUG - HostKey: ssh-rsa 2025-07-15 14:21:29,631 - DEBUG - Cipher: aes128-cbc 2025-07-15 14:21:29,631 - DEBUG - MAC: hmac-sha1 2025-07-15 14:21:29,632 - DEBUG - Compression: none 2025-07-15 14:21:29,632 - DEBUG - === End of kex handshake === 2025-07-15 14:21:29,655 - DEBUG - Got server p (2048 bits) 2025-07-15 14:21:30,462 - DEBUG - kex engine KexGex specified hash_algo <built-in function openssl_sha1> 2025-07-15 14:21:30,462 - DEBUG - Switch to new keys ... 2025-07-15 14:21:30,463 - DEBUG - Adding ssh-rsa host key for 172.17.201.28: b'5e3ca5910d7cce29466ca9634fce6a23' 2025-07-15 14:21:30,486 - DEBUG - userauth is OK 2025-07-15 14:21:30,506 - INFO - Authentication (password) successful! 2025-07-15 14:21:30,507 - DEBUG - [chan 0] Max packet in: 32768 bytes 2025-07-15 14:21:30,528 - DEBUG - [chan 0] Max packet out: 32496 bytes 2025-07-15 14:21:30,528 - DEBUG - Secsh channel 0 opened. 2025-07-15 14:21:30,532 - DEBUG - [chan 0] Sesch channel 0 request ok 2025-07-15 14:21:30,536 - DEBUG - [chan 0] Sesch channel 0 request ok 2025-07-15 14:21:30,536 - DEBUG - write_channel: b'\n' 2025-07-15 14:21:30,638 - DEBUG - read_channel: ****************************************************************************** * Copyright (c) 2004-2013 Hangzhou H3C Tech. Co., Ltd. All rights reserved. * * Without the owner's prior written consent, * * no decompiling or reverse-engineering shall be allowed. * ****************************************************************************** <CDSL_SW201.28_LBG> 2025-07-15 14:21:30,638 - DEBUG - Pattern found: (to continue|[>\]]) ****************************************************************************** * Copyright (c) 2004-2013 Hangzhou H3C Tech. Co., Ltd. All rights reserved. * * Without the owner's prior written consent, * * no decompiling or reverse-engineering shall be allowed. * ****************************************************************************** <CDSL_SW201.28_LBG> 2025-07-15 14:21:30,939 - DEBUG - read_channel: <CDSL_SW201.28_LBG> 2025-07-15 14:21:30,939 - DEBUG - Clear buffer detects data in the channel 2025-07-15 14:21:31,540 - DEBUG - read_channel: 2025-07-15 14:21:31,540 - DEBUG - write_channel: b'\n' 2025-07-15 14:21:31,540 - DEBUG - read_channel: 2025-07-15 14:21:31,551 - DEBUG - read_channel: <CDSL_SW201.28_LBG> 2025-07-15 14:21:31,551 - DEBUG - Parenthesis found in pattern. pattern: (>|\]) This can be problemtic when used in read_until_pattern(). You should ensure that you use either non-capture groups i.e. '(?:' or that the parenthesis completely wrap the pattern '(pattern)' 2025-07-15 14:21:31,551 - DEBUG - Pattern found: (>|\]) <CDSL_SW201.28_LBG> 2025-07-15 14:21:31,852 - DEBUG - read_channel: 2025-07-15 14:21:31,852 - DEBUG - [find_prompt()]: prompt is <CDSL_SW201.28_LBG> 2025-07-15 14:21:31,852 - DEBUG - In disable_paging 2025-07-15 14:21:31,852 - DEBUG - Command: screen-length disable 2025-07-15 14:21:31,852 - DEBUG - write_channel: b'screen-length disable\n' 2025-07-15 14:21:31,852 - DEBUG - read_channel: 2025-07-15 14:21:31,863 - DEBUG - read_channel: s 2025-07-15 14:21:31,874 - DEBUG - read_channel: 2025-07-15 14:21:31,885 - DEBUG - read_channel: creen-length disable 2025-07-15 14:21:31,896 - DEBUG - read_channel: 2025-07-15 14:21:31,907 - DEBUG - read_channel: ^ % Unrecognized command found at '^' position. <CDSL_SW201.28_LBG> 2025-07-15 14:21:31,907 - DEBUG - Pattern found: (CDSL_SW201\.28_LBG) screen-length disable ^ % Unrecognized command found at '^' position. <CDSL_SW201.28_LBG 2025-07-15 14:21:31,907 - DEBUG - screen-length disable ^ % Unrecognized command found at '^' position. <CDSL_SW201.28_LBG 2025-07-15 14:21:31,907 - DEBUG - Exiting disable_paging 2025-07-15 14:21:31,907 - INFO - 成功连接 172.17.201.28 2025-07-15 14:21:31,907 - DEBUG - write_channel: b'screen-length disable\n' 2025-07-15 14:21:32,008 - DEBUG - read_channel: screen-length disable ^ % Unrecognized command found at '^' position. <CDSL_SW201.28_LBG> 2025-07-15 14:21:32,108 - DEBUG - read_channel: 2025-07-15 14:21:34,109 - DEBUG - read_channel: 2025-07-15 14:21:34,610 - DEBUG - write_channel: b'system-view\n' 2025-07-15 14:21:34,711 - DEBUG - read_channel: system-view ^ % Unrecognized command found at '^' position. <CDSL_SW201.28_LBG> 2025-07-15 14:21:34,812 - DEBUG - read_channel: 2025-07-15 14:21:36,813 - DEBUG - read_channel: 2025-07-15 14:21:37,814 - INFO - 172.17.201.28 是 H3C V5 交换机,使用特殊绑定流程 2025-07-15 14:21:37,814 - DEBUG - write_channel: b'display mac-address 6c0b-5e47-7f89\n' 2025-07-15 14:21:37,915 - DEBUG - read_channel: display mac-address 6c0b-5e47-7f89 ^ % Unrecognized command found at '^' position. <CDSL_SW201.28_LBG> 2025-07-15 14:21:38,016 - DEBUG - read_channel: 2025-07-15 14:21:40,018 - DEBUG - read_channel: 2025-07-15 14:21:40,018 - INFO - MAC地址查询结果: ^ % Unrecognized command found at '^' position. 2025-07-15 14:21:40,018 - ERROR - 在 172.17.201.28 上未找到 MAC 6c0b-5e47-7f89 对应的端口 2025-07-15 14:21:40,019 - DEBUG - write_channel: b'\n' 2025-07-15 14:21:40,120 - DEBUG - read_channel: <CDSL_SW201.28_LBG> 2025-07-15 14:21:40,221 - DEBUG - read_channel: 2025-07-15 14:21:42,222 - DEBUG - read_channel: 2025-07-15 14:21:42,222 - DEBUG - write_channel: b'quit\n' 2025-07-15 14:21:42,222 - DEBUG - EOF in transport thread

filetype

[root@localhost ~]# ssh -vT [email protected] OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 58: Applying options for * debug1: Connecting to gitee.com [180.76.198.225] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: identity file /root/.ssh/id_ed25519 type 4 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.4 debug1: Remote protocol version 2.0, remote software version ssh-pilot-1.8.4 debug1: no match: ssh-pilot-1.8.4 debug1: Authenticating to gitee.com:22 as 'git' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none debug1: kex: curve25519-sha256 need=64 dh_need=64 debug1: kex: curve25519-sha256 need=64 dh_need=64 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc debug1: Host 'gitee.com' is known and matches the ECDSA host key. debug1: Found key in /root/.

filetype

penSSH_8.9p1 Ubuntu-3ubuntu0.13, OpenSSL 3.0.2 15 Mar 2022 debug1: Reading configuration data /home/naura/.ssh/config debug1: /home/naura/.ssh/config line 4: Applying options for *.*.*.* debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * debug2: resolve_canonicalize: hostname 172.21.42.11 is address debug1: Connecting to 172.21.42.11 [172.21.42.11] port 22. debug1: Connection established. debug1: identity file /home/naura/.ssh/id_rsa type 0 debug1: identity file /home/naura/.ssh/id_rsa-cert type -1 debug1: identity file /home/naura/.ssh/id_ecdsa type -1 debug1: identity file /home/naura/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/naura/.ssh/id_ecdsa_sk type -1 debug1: identity file /home/naura/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /home/naura/.ssh/id_ed25519 type -1 debug1: identity file /home/naura/.ssh/id_ed25519-cert type -1 debug1: identity file /home/naura/.ssh/id_ed25519_sk type -1 debug1: identity file /home/naura/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /home/naura/.ssh/id_xmss type -1 debug1: identity file /home/naura/.ssh/id_xmss-cert type -1 debug1: identity file /home/naura/.ssh/id_dsa type -1 debug1: identity file /home/naura/.ssh/id_dsa-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.13 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: compat_banner: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000002 debug2: fd 3 setting O_NONBLOCK debug1: Authenticating to 172.21.42.11:22 as 'naura' debug1: load_hostkeys: fopen /home/naura/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug2: local client KEXINIT proposal debug2: KEX algorithms: curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,[email protected],diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c,[email protected] debug2: host key algorithms: [email protected],[email protected],rsa-sha2-512,rsa-sha2-256,ssh-rsa,[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected] debug2: ciphers ctos: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] debug2: ciphers stoc: [email protected],aes128-ctr,aes192-ctr,aes256-ctr,[email protected],[email protected] debug2: MACs ctos: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: MACs stoc: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: compression ctos: none,[email protected],zlib debug2: compression stoc: none,[email protected],zlib debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug2: peer server KEXINIT proposal debug2: KEX algorithms: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 debug2: host key algorithms: ssh-rsa,ssh-dss debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] debug2: MACs ctos: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: MACs stoc: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 debug2: compression ctos: none,[email protected] debug2: compression stoc: none,[email protected] debug2: languages ctos: debug2: languages stoc: debug2: first_kex_follows 0 debug2: reserved 0 debug1: kex: algorithm: diffie-hellman-group-exchange-sha256 debug1: kex: host key algorithm: ssh-rsa debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug1: SSH2_MSG_KEX_DH_GEX_GROUP received debug2: bits set: 1561/3072 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: SSH2_MSG_KEX_DH_GEX_REPLY received debug1: Server host key: ssh-rsa SHA256:OzbixG+2Q88/j+Y7Wydz0dSg/doWAoaatpF8lCHUSO4 debug1: load_hostkeys: fopen /home/naura/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: Host '172.21.42.11' is known and matches the RSA host key. debug1: Found key in /home/naura/.ssh/known_hosts:9 debug2: bits set: 1509/3072 debug2: ssh_set_newkeys: mode 1 debug1: rekey out after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug2: ssh_set_newkeys: mode 0 debug1: rekey in after 4294967296 blocks debug1: get_agent_identities: bound agent to hostkey debug1: get_agent_identities: agent returned 1 keys debug1: Will attempt key: /home/naura/.ssh/id_rsa RSA SHA256:o3g0EOxHAeTeLlN8YskjQmqZCoW6RU9VWDNsKe6maYE agent debug1: Will attempt key: /home/naura/.ssh/id_ecdsa debug1: Will attempt key: /home/naura/.ssh/id_ecdsa_sk debug1: Will attempt key: /home/naura/.ssh/id_ed25519 debug1: Will attempt key: /home/naura/.ssh/id_ed25519_sk debug1: Will attempt key: /home/naura/.ssh/id_xmss debug1: Will attempt key: /home/naura/.ssh/id_dsa debug2: pubkey_prepare: done debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Next authentication method: gssapi-with-mic debug1: No credentials were supplied, or the credentials were unavailable or inaccessible No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000) debug1: No credentials were supplied, or the credentials were unavailable or inaccessible No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000) debug2: we did not send a packet, disable method debug1: Next authentication method: publickey debug1: Offering public key: /home/naura/.ssh/id_rsa RSA SHA256:o3g0EOxHAeTeLlN8YskjQmqZCoW6RU9VWDNsKe6maYE agent debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password debug1: Trying private key: /home/naura/.ssh/id_ecdsa debug1: Trying private key: /home/naura/.ssh/id_ecdsa_sk debug1: Trying private key: /home/naura/.ssh/id_ed25519 debug1: Trying private key: /home/naura/.ssh/id_ed25519_sk debug1: Trying private key: /home/naura/.ssh/id_xmss debug1: Trying private key: /home/naura/.ssh/id_dsa debug2: we did not send a packet, disable method debug1: Next authentication method: password [email protected]'s password:

filetype

明确下:pgbouncer/lib/usual/mbuf.h 里有 _MUSTCHECK static inline bool mbuf_get_bytes(struct MBuf *buf, unsigned len, const uint8_t **dst_p) { if (buf->read_pos + len > buf->write_pos) return false; *dst_p = buf->data + buf->read_pos; buf->read_pos += len; return true; } 如下是添加了sm3处理的answer_authreq,是否正确? /* answer server authentication request */ bool answer_authreq(PgSocket *server, PktHdr *pkt) { uint32_t cmd; const uint8_t *salt; bool res = false; /* authreq body must contain 32bit cmd */ if (mbuf_avail_for_read(&pkt->data) < 4) return false; if (!mbuf_get_uint32be(&pkt->data, &cmd)) return false; switch (cmd) { case AUTH_OK: slog_debug(server, "S: auth ok"); res = true; break; case AUTH_PLAIN: slog_debug(server, "S: req cleartext password"); res = login_clear_psw(server); break; case AUTH_MD5: slog_debug(server, "S: req md5-crypted psw"); if (!mbuf_get_bytes(&pkt->data, 4, &salt)) return false; res = login_md5_psw(server, salt); break; case AUTH_SM3: slog_debug(server, "S: req sm3-crypted psw"); if (!mbuf_get_bytes(&pkt->data, SM3_SALT_LENGTH, &salt)) return false; res = login_sm3_psw(server, salt); break; case AUTH_SASL: { bool selected_mechanism = false; slog_debug(server, "S: req SASL"); do { const char *mech; if (!mbuf_get_string(&pkt->data, &mech)) return false; if (!mech[0]) break; slog_debug(server, "S: SASL advertised mechanism: %s", mech); if (strcmp(mech, "SCRAM-SHA-256") == 0) selected_mechanism = true; } while (!selected_mechanism); if (!selected_mechanism) { slog_error(server, "none of the server's SASL authentication mechanisms are supported"); kill_pool_logins(server->pool, "server login failed: none of the server's SASL authentication mechanisms are supported"); } else res = login_scram_sha_256(server); break; } case AUTH_SASL_CONT: { unsigned len; const uint8_t *data; slog_debug(server, "S: SASL cont"); len = mbuf_avail_for_read(&pkt->data); if (!mbuf_get_bytes(&pkt->data, len, &data)) return false; res = login_scram_sha_256_cont(server, len, data); break; } case AUTH_SASL_FIN: { unsigned len; const uint8_t *data; slog_debug(server, "S: SASL final"); len = mbuf_avail_for_read(&pkt->data); if (!mbuf_get_bytes(&pkt->data, len, &data)) return false; res = login_scram_sha_256_final(server, len, data); free_scram_state(&server->scram_state); break; } default: slog_error(server, "unknown/unsupported auth method: %d", cmd); res = false; break; } return res; }

filetype

++ -c -include .pch/Qt5Core -pipe -O3 -std=c++11 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -Wno-format-overflow -D_REENTRANT -fPIC -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DELF_INTERPRETER=\"/lib/ld-linux-aarch64.so.1\" -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DPCRE2_CODE_UNIT_WIDTH=16 -I. -Iglobal -I../3rdparty/md5 -I../3rdparty/md4 -I../3rdparty/sha3 -I../3rdparty -I../3rdparty/double-conversion/include -I../3rdparty/harfbuzz/src -I../3rdparty/forkfd -I../3rdparty/tinycbor/src -I.rcc -I../../include -I../../include/QtCore -I../../include/QtCore/5.15.17 -I../../include/QtCore/5.15.17/QtCore -I.moc -I.tracegen -I../3rdparty/pcre2/src -I../../mkspecs/linux-g++ -o .obj/qabstractitemmodel.o itemmodels/qabstractitemmodel.cpp itemmodels/qabstractitemmodel.cpp: In member function ‘bool QPersistentModelIndex::operator<(const QPersistentModelIndex&) const’: itemmodels/qabstractitemmodel.cpp:218:22: error: wrong number of template arguments (0, should be 1) 218 | return std::less<>{}(d, other.d); | ^ In file included from /usr/include/c++/13/string:49, from ../../include/QtCore/../../src/corelib/text/qbytearray.h:52, from ../../include/QtCore/qbytearray.h:1, from ../../include/QtCore/../../src/corelib/text/qstring.h:50, from ../../include/QtCore/qstring.h:1, from ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:44, from ../../include/QtCore/qcoreapplication.h:1, from global/qt_pch.h:66: /usr/include/c++/13/bits/stl_function.h:403:12: note: provided for ‘template<class _Tp> struct std::less’ 403 | struct less : public binary_function<_Tp, _Tp, bool> | ^~~~ make[3]: *** [Makefile:41096:.obj/qabstractitemmodel.o] 错误 1 make[3]: *** 正在等待未完成的任务.... make[3]: 离开目录“/opt/qt-everywhere-src-5.15.17/qtbase/src/corelib” make[2]: *** [Makefile:202:sub-corelib-make_first] 错误 2 make[2]: 离开目录“/opt/qt-everywhere-src-5.15.17/qtbase/src” make[1]: *** [Makefile:51:sub-src-make_first] 错误 2 make[1]: 离开目录“/opt/qt-everywhere-src-5.15.17/qtbase” make: *** [Makefile:85:module-qtbase] 错误 2

filetype

这是 pgbouncer 1.12.0 的源码的 pgbouncer/src/client.c 的部分代码: #include "bouncer.h" #include "pam.h" #include "scram.h" #include <usual/pgutil.h> static const char *hdr2hex(const struct MBuf *data, char *buf, unsigned buflen) { const uint8_t *bin = data->data + data->read_pos; unsigned int dlen; dlen = mbuf_avail_for_read(data); return bin2hex(bin, dlen, buf, buflen); } static bool check_client_passwd(PgSocket *client, const char *passwd) { char md5[MD5_PASSWD_LEN + 1]; PgUser *user = client->auth_user; int auth_type = client->client_auth_type; /* disallow empty passwords */ if (!*passwd || !*user->passwd) return false; switch (auth_type) { case AUTH_PLAIN: switch (get_password_type(user->passwd)) { case PASSWORD_TYPE_PLAINTEXT: return strcmp(user->passwd, passwd) == 0; case PASSWORD_TYPE_MD5: pg_md5_encrypt(passwd, user->name, strlen(user->name), md5); return strcmp(user->passwd, md5) == 0; case PASSWORD_TYPE_SCRAM_SHA_256: return scram_verify_plain_password(client, user->name, passwd, user->passwd); default: return false; } case AUTH_MD5: if (strlen(passwd) != MD5_PASSWD_LEN) return false; if (get_password_type(user->passwd) == PASSWORD_TYPE_PLAINTEXT) pg_md5_encrypt(user->passwd, user->name, strlen(user->name), user->passwd); pg_md5_encrypt(user->passwd + 3, (char *)client->tmp_login_salt, 4, md5); return strcmp(md5, passwd) == 0; } return false; } static bool send_client_authreq(PgSocket *client) { int res; int auth_type = client->client_auth_type; if (auth_type == AUTH_MD5) { uint8_t saltlen = 4; get_random_bytes((void*)client->tmp_login_salt, saltlen); SEND_generic(res, client, 'R', "ib", AUTH_MD5, client->tmp_login_salt, saltlen); } else if (auth_type == AUTH_PLAIN || auth_type == AUTH_PAM) { SEND_generic(res, client, 'R', "i", AUTH_PLAIN); } else if (auth_type == AUTH_SCRAM_SHA_256) { SEND_generic(res, client, 'R', "iss", AUTH_SASL, "SCRAM-SHA-256", ""); } else { return false; } if (!res) disconnect_client(client, false, "failed to send auth req"); return res; } static void start_auth_request(PgSocket *client, const char *username) { int res; PktBuf *buf; /* have to fetch user info from db */ client->pool = get_pool(client->db, client->db->auth_user); if (!find_server(client)) { client->wait_for_user_conn = true; return; } slog_noise(client, "doing auth_conn query"); client->wait_for_user_conn = false; client->wait_for_user = true; if (!sbuf_pause(&client->sbuf)) { release_server(client->link); disconnect_client(client, true, "pause failed"); return; } client->link->ready = 0; res = 0; buf = pktbuf_dynamic(512); if (buf) { pktbuf_write_ExtQuery(buf, cf_auth_query, 1, username); res = pktbuf_send_immediate(buf, client->link); pktbuf_free(buf); /* * Should do instead: * res = pktbuf_send_queued(buf, client->link); * but that needs better integration with SBuf. */ } if (!res) disconnect_server(client->link, false, "unable to send login query"); } static bool login_via_cert(PgSocket *client) { struct tls *tls = client->sbuf.tls; if (!tls) { disconnect_client(client, true, "TLS connection required"); return false; } if (!tls_peer_cert_provided(client->sbuf.tls)) { disconnect_client(client, true, "TLS client certificate required"); return false; } log_debug("TLS cert login: %s", tls_peer_cert_subject(client->sbuf.tls)); if (!tls_peer_cert_contains_name(client->sbuf.tls, client->auth_user->name)) { disconnect_client(client, true, "TLS certificate name mismatch"); return false; } /* login successful */ return finish_client_login(client); } static bool login_as_unix_peer(PgSocket *client) { if (!pga_is_unix(&client->remote_addr)) goto fail; if (!check_unix_peer_name(sbuf_socket(&client->sbuf), client->auth_user->name)) goto fail; return finish_client_login(client); fail: disconnect_client(client, true, "unix socket login rejected"); return false; } 讲解下

filetype

2025-07-03T14:27:05.799533225+08:00 stdout F 06:27:05.799 [main] DEBUG io.netty.handler.ssl.OpenSsl - Supported protocols (OpenSSL): [SSLv2Hello, TLSv1, TLSv1.1, TLSv1.2, TLSv1.3] 2025-07-03T14:27:05.799601063+08:00 stdout F 06:27:05.799 [main] DEBUG io.netty.handler.ssl.OpenSsl - Default cipher suites (OpenSSL): [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384] 2025-07-03T14:27:05.940850208+08:00 stdout F Exception (org.apache.cassandra.exceptions.ConfigurationException) encountered during startup: Invalid yaml. Those properties [thrift_prepared_statements_cache_size_mb] are not valid 2025-07-03T14:27:05.940921257+08:00 stderr F Invalid yaml. Those properties [thrift_prepared_statements_cache_size_mb] are not valid 2025-07-03T14:27:05.941107882+08:00 stdout F 06:27:05.940 [main] ERROR org.apache.cassandra.service.CassandraDaemon - Exception encountered during startup: Invalid yaml. Those properties [thrift_prepared_statements_cache_size_mb] are not valid ^C [root@node1 cassandra]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 21490d5a5e68 docker.io/library/cassandra:4.0 cassandra -f 2 minutes ago Exited (3) 2 minutes ago 0.0.0.0:9042->9042/tcp cassandra 这是日志为什么启动失败

filetype
filetype

Execution failed for task ':app:buildCMakeDebug[x86_64]'. > com.android.ide.common.process.ProcessException: ninja: Entering directory `D:\xjyWork\SF4310_sof\SF4310_AR\app\.cxx\Debug\5v4l4e3w\x86_64' [1/1] Linking CXX shared library D:\xjyWork\SF4310_sof\SF4310_AR\app\build\intermediates\cxx\Debug\5v4l4e3w\obj\x86_64\libexample.so FAILED: D:/xjyWork/SF4310_sof/SF4310_AR/app/build/intermediates/cxx/Debug/5v4l4e3w/obj/x86_64/libexample.so cmd.exe /C "cd . && C:\Users\32182\AppData\Local\Android\Sdk\ndk\27.0.12077973\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=x86_64-none-linux-android28 --sysroot=C:/Users/32182/AppData/Local/Android/Sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fopenmp=libomp -fno-limit-debug-info -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--no-undefined-version -Wl,--fatal-warnings -Wl,--no-undefined -Qunused-arguments -shared -Wl,-soname,libexample.so -o D:\xjyWork\SF4310_sof\SF4310_AR\app\build\intermediates\cxx\Debug\5v4l4e3w\obj\x86_64\libexample.so CMakeFiles/example.dir/Reco.cpp.o CMakeFiles/example.dir/JNIReco.cpp.o D:/xjyWork/SF4310_sof/SF4310_AR/app/src/main/cpp/../../../src/libs/x86_64/libncnn.so -lopencv_java4 -landroid -llog -ljnigraphics -latomic -lm && cd ." ld.lld: error: unable to find library -lopencv_java4 clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. * Try: > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. 怎么改

海四
  • 粉丝: 69
上传资源 快速赚钱