[BACK]Return to bufec.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/bufec.c, Revision 1.4

1.4     ! djm         1: /* $OpenBSD$ */
        !             2:
1.1       djm         3: /*
1.4     ! djm         4:  * Copyright (c) 2012 Damien Miller <djm@mindrot.org>
1.1       djm         5:  *
                      6:  * Permission to use, copy, modify, and distribute this software for any
                      7:  * purpose with or without fee is hereby granted, provided that the above
                      8:  * copyright notice and this permission notice appear in all copies.
                      9:  *
                     10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     17:  */
                     18:
1.4     ! djm        19: /* Emulation wrappers for legacy OpenSSH buffer API atop sshbuf */
1.1       djm        20:
1.4     ! djm        21: #include <sys/types.h>
1.1       djm        22:
                     23: #include "buffer.h"
                     24: #include "log.h"
1.4     ! djm        25: #include "ssherr.h"
1.1       djm        26:
                     27: int
                     28: buffer_put_ecpoint_ret(Buffer *buffer, const EC_GROUP *curve,
                     29:     const EC_POINT *point)
                     30: {
1.4     ! djm        31:        int ret;
        !            32:
        !            33:        if ((ret = sshbuf_put_ec(buffer, point, curve)) != 0) {
        !            34:                error("%s: %s", __func__, ssh_err(ret));
        !            35:                return -1;
1.1       djm        36:        }
1.4     ! djm        37:        return 0;
1.1       djm        38: }
                     39:
                     40: void
                     41: buffer_put_ecpoint(Buffer *buffer, const EC_GROUP *curve,
                     42:     const EC_POINT *point)
                     43: {
                     44:        if (buffer_put_ecpoint_ret(buffer, curve, point) == -1)
                     45:                fatal("%s: buffer error", __func__);
                     46: }
                     47:
                     48: int
                     49: buffer_get_ecpoint_ret(Buffer *buffer, const EC_GROUP *curve,
                     50:     EC_POINT *point)
                     51: {
1.4     ! djm        52:        int ret;
1.1       djm        53:
1.4     ! djm        54:        if ((ret = sshbuf_get_ec(buffer, point, curve)) != 0) {
        !            55:                error("%s: %s", __func__, ssh_err(ret));
1.1       djm        56:                return -1;
                     57:        }
1.4     ! djm        58:        return 0;
1.1       djm        59: }
                     60:
                     61: void
                     62: buffer_get_ecpoint(Buffer *buffer, const EC_GROUP *curve,
                     63:     EC_POINT *point)
                     64: {
                     65:        if (buffer_get_ecpoint_ret(buffer, curve, point) == -1)
                     66:                fatal("%s: buffer error", __func__);
                     67: }
1.4     ! djm        68:
1.1       djm        69: