MCPcopy Index your code
hub / github.com/git/git / plain_base64

Function plain_base64

imap-send.c:879–909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

877
878#define ENCODED_SIZE(n) (4 * DIV_ROUND_UP((n), 3))
879static char *plain_base64(const char *user, const char *pass)
880{
881 struct strbuf raw = STRBUF_INIT;
882 int b64_len;
883 char *b64;
884
885 /*
886 * Compose the PLAIN string
887 *
888 * The username and password are combined to one string and base64 encoded.
889 * "\0user\0pass"
890 *
891 * The method has been described in RFC4616.
892 *
893 * https://datatracker.ietf.org/doc/html/rfc4616
894 */
895 strbuf_addch(&raw, '\0');
896 strbuf_addstr(&raw, user);
897 strbuf_addch(&raw, '\0');
898 strbuf_addstr(&raw, pass);
899
900 b64 = xmallocz(ENCODED_SIZE(raw.len));
901 b64_len = EVP_EncodeBlock((unsigned char *)b64, (unsigned char *)raw.buf, raw.len);
902 strbuf_release(&raw);
903
904 if (b64_len < 0) {
905 free(b64);
906 return NULL;
907 }
908 return b64;
909}
910
911static char *cram(const char *challenge_64, const char *user, const char *pass)
912{

Callers 1

auth_plainFunction · 0.85

Calls 4

strbuf_addchFunction · 0.85
strbuf_addstrFunction · 0.85
xmalloczFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected